tkinter questions: behavior of StringVar, etc

John Posner jjposner at snet.net
Mon Mar 30 12:25:38 EDT 2009


Eric Brunel said:

 >> The Tk instance is registered in a hidden variable in the 
 >> Tkinter module. When
 >> you don't specify a master, it'll use the latest created Tk 
 >> instance one by
 >> default. BTW, the latest should be the only one: it is 
 >> quite unsafe to create
 >> several Tk instances in the same application.

Again, "latest" is incorrect for IDLE 2.6.1:

    >>> from Tkinter import *
    >>> root1 = Tk()
    >>> root2 = Tk()
    >>> root3 = Tk()
    >>> frm = Frame()       # no master specified
    >>> frm.master is root3
    False
    >>> frm.master is root1
    True

 >> Well, I personnally don't see any point on doing any master creation
 >> implicitely, so I never use this master auto-creation for 
 >> anything.

+1. "Explicit is better than implicit."

-John





E-mail message checked by Spyware Doctor (6.0.0.386)
Database version: 5.12070
http://www.pctools.com/en/spyware-doctor-antivirus/



More information about the Python-list mailing list