Michael; Thank you very much. I'm kinda new to Python and Tkinter, and didn't know anything about Toplevel, that was exactly what I need.
But tell me, why I can't use two instances of Tk? The way I saw this, was that I was just creating a new object, so I don't understand what is the problem in creating a second object of Tk. I know it doesn't work, but I will like to understand why. If you don't know the answer, don't mind. Thank you very much anyway. You really help me on this one. Charras On Apr 2, 2010, at 4:00 AM, [email protected] wrote: > Send Tkinter-discuss mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tkinter-discuss > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tkinter-discuss digest..." > > > Today's Topics: > > 1. Re: Labels not updating its display data (Michael Lange) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 1 Apr 2010 12:27:12 +0200 > From: Michael Lange <[email protected]> > To: [email protected] > Subject: Re: [Tkinter-discuss] Labels not updating its display data > Message-ID: <[email protected]> > Content-Type: text/plain; charset=US-ASCII > > Hi Guido, > > On Thu, 01 Apr 2010 00:02:36 -0600 > Guido Carballo-Guerrero <[email protected]> wrote: > >> 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: >> >> > (...) >> 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() > > There are two problems in this function, first you should _never_ use > two instances of Tk() in one program; if you need a second window, use > a Tkinter.Toplevel() instead. > Second, you assign var1 as textvariable for the Label; I think what you > actually intended is to set the current value of var1 as initial value > for var2 and then use var2 as textvariable for the label ? If yes, > simply change the first lines of newcount() into: > > def newcount(): > > root2 = Tkt.Toplevel() > var2 = Tkt.IntVar() > var2.set(var1.get()) > > I hope this helps > > Michael > > > > > > > ------------------------------ > > _______________________________________________ > Tkinter-discuss mailing list > [email protected] > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > End of Tkinter-discuss Digest, Vol 74, Issue 2 > ********************************************** _______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
