Tkinter listener | Sololearn: Learn to code for FREE!


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.

11/3/2018 10:56:45 PM

Toni Sedjoah

1 Answer

New Answer


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.