Proposal: Making Tkinter easier to use for "sinners" converted from Perl/Tk ;-)

Peter Funk pf at artcom-gmbh.de
Thu Mar 16 03:56:40 EST 2000


Hi!

Long time Python/Tkinter users know, that the Tkinter widget methods 
w.pack(), w.grid() and w.place() return 'None'.  This is different 
from Perl/Tk, where users can do something like this (here shown in 
Python syntax in order to treat your stomach with appropriate care):
     import Tkinter
     r = Tkinter.Tk()
     f = Tkinter.Frame().pack()                   # <--- !
     l = Tkinter.Label(f, text="Foo bar").grid()  # <--- !
     r.mainloop()
(Insiders will notice, that the outlined example will go into the well known
 geometry fighting infinite loop... ;-) 
Currently you have to write the offending two lines as:
     f = Tkinter.Frame(); f.pack()
     l = Tkinter.Label(f, text="Foo bar"); l.grid()
because 'f' and 'l' would become 'None' otherwise.  However to
make the former work, only 3 small changes to $PYTHON/lib/lib-tk/Tkinter.py 
are required:  Appeding a 'return self' to the methods 'Pack.pack_configure',
'Grid.grid_configure' and 'Place.place_configure' would do the trick.

Now I wonder, whether existing Python/Tkinter apps could break from 
such a change, because they make some use of the 'None' value currently
returned by the 'pack', 'grid' and 'place' methods?

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)




More information about the Python-list mailing list