python 2.7 - Performing tasks on input given by entry and updating label constantly -
so im little new tkinter , making gui. 1 of problems having when got value entry widget. not labels associated entry widget update after had done arithmetic it. example
var = tk.stringvar entry1 = tk.entry(root, textvariable = var) entry1.pack() var label1 = tk.label(root, text = var) label1.pack()
i looked around before asking , found connect variables. tried still not update after first time.
how label update everytime new value entered in entry. if 2 entered 4 displayed. if entered 5 label should update automatically , 10 should dislplayed. in case im multiplying two. label should update until close program.
thanks having alot of trouble figuring out appreciated
def enter_hit(event): do_something_with(var.get()) var = tk.stringvar entry1 = tk.entry(root, textvariable = var) entry1.pack() label1 = tk.label(root, text = var) label1.pack() entry1.bind("<return>",enter_hit)
when hit enter on entry1
, calls enter_hit. var
, it's text can gotten, , can want affect label1
.
if doesn't suit you, , want change moment character inputted, try trace.
def traced_event(event): do_something_with(var.get()) var = tk.stringvar entry1 = tk.entry(root, textvariable = var) entry1.pack() label1 = tk.label(root, text = var) label1.pack() var.trace("w", traced_event)
Comments
Post a Comment