+ 2
Tkinter listener
I'm working on a simple GUI with tkinter and I want to know if I can create something like a "listener" for a text Entry so tat once the Entry is populated some functions begin to run. I've tried using events & bindings but with no success.
1 ответ
+ 1
Try using get().
You will still have to have a "button" to trigger the function, but it will assign the value of the input to a variable that can be used in the function.
yourVariable = StringVar()
first_entry = ttk.Entry(mainframe, width=25, textvariable=yourVariable)
first_entry.grid(column=2, row=1, sticky=(W, E))
ttk.Label(mainframe, text="Your Entry Field:").grid(column=1, row=1, sticky=W)
ttk.Button(mainframe, text="Submit", command = yourFunctionName).grid(column=3, row=3, sticky=W)
If the code is set up similar to the above then when you call the yourVariable.get() in your function code, the input field value will be assigned to your variable.