How to access multiple variables containing inputs from entry boxes in tkinter from one script and use it in another script?

Viewed 15

How can I access multiple variables containing user inputs from Entry widgets from one script and use it in another function in another script? I can find information on how to do this with one input, but nothing regarding multiple ones.

For example, say I have one script:

Main.py

from tkinter import *
import main

root = Tk()

entry = Entry(root)
entry.pack()

btn = Button(root, text='', command=lambda: main.showInput(entry.get()))
btn.pack()

root.mainloop()

class.py

def showInput(x):
    print(x)

will work and print out the value. If I have multiple entries I could change the function to show

def showInput(x, y):
    print(x)
    print(y)

and make the corrections adjustments in the button widget on main.py. However, this isn't practical as I add more and more entries - especially since I'd like to make this work with docxtpl after I figure out this issue. What would the best way to handle this be?

0 Answers
Related