Is it possible to display and update data using labels in a window, created by
another window?
This is a program I did that is not working as expected:
import Tkinter as Tkt
root1 = Tkt.Tk( )
var1 = Tkt.IntVar()
frameLabels1 = Tkt.Frame(root1)
frameLabels1.pack()
Tkt.Label(frameLabels1,text='var1 :').pack(side=Tkt.LEFT)
Tkt.Label(frameLabels1,textvariable=var1).pack(side=Tkt.LEFT)
def newcount():
root2 = Tkt.Tk()
var2 = Tkt.IntVar()
frameLabels2 = Tkt.Frame(root2)
frameLabels2.pack()
def changeVal():
var2.set(var2.get()+1)
print 'var2: ',var2.get()
Tkt.Label(frameLabels2,text='var2: ').pack(side=Tkt.LEFT)
Tkt.Label(frameLabels2,textvariable=var1).pack(side=Tkt.LEFT)
Tkt.Button(root2,text="Change value", command=changeVal).pack()
root2.mainloop()
Tkt.Button(text="New Count W", command=newcount).pack()
def changeVal1():
c = 0
while c < 10:
var1.set(var1.get()+1)
print 'var1 = ', var1.get()
if var1.get() > 100:
var1.set(0)
## time.sleep(.5)
c += 1
Tkt.Button(text="Change value1", command=changeVal1).pack(side=Tkt.LEFT)
root1.mainloop( )
I'm creating a second window inside of a function call newcount. This other
window even have separate variables, but if I use the label type of display,
that data is not show, and even less chage its value.
Can somebody tell me if it's possible to do what I'm trying? How can I display
a value inside of a label, and have that display update its values, when this
is trying to be done in a second window.
Guido
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss