1from Tkinter import *
2
3#------------------------------------
4
5def my_tracer(a, b, c): # trace send 3 arguments to my_tracer
6 #print a, b, c
7
8 # using StringVar to get and set text
9 new_text = e1_var.get() + e2_var.get()
10 t_var.set(new_text)
11
12#------------------------------------
13
14top = Tk()
15
16#---
17
18t_var = StringVar() # or StringVar(top)
19
20t = Label(top, textvariable=t_var)
21t.pack()
22
23#---
24
25e1_var = StringVar() # or StringVar(top)
26e1_var.trace('w', my_tracer) # run my_tracer if value was changed (w = write)
27
28e1 = Entry(top, textvariable=e1_var)
29e1.pack()
30
31#---
32
33e2_var = StringVar() # or StringVar(top)
34e2_var.trace('w', my_tracer) # run my_tracer if value was changed (w = write)
35
36e2 = Entry(top, textvariable=e2_var)
37e2.pack()
38
39#---
40
41top.mainloop()
42
43#-----------------------------------