Hi Guido, On Fri, 02 Apr 2010 12:32:03 -0600 Guido Carballo-Guerrero <char...@me.com> wrote:
> 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. > I will try to explain, though I am not a no.1 expert :) The Tk() window is not just a widget, like a Button or a Toplevel, but has its own associated Tcl interpreter which is controlled through Python; so if you have two Tk instances in your application, you have two different Tcl interpreters running. As you noticed in your first code example, this did work, but not exactly as you expected. The reason is that the two Tcl interpreters cause some unwanted side effects, because they can coexist, but not interact; for example, (IIRC) you created two IntVars, but IntVar2 inside the second Tcl interpreter, which will not work when trying to use it as textvariable for a Label belonging to Tcl interpreter #1 ; if the application becomes more complex, it will obviously become hard to avoid running into traps like this, when OTOH there is not really a benefit from the second Tk() window. I hope this helps Michael _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss