Tk packing problem, in_ parameter fails?
Russell E. Owen
owen at nospam.invalid
Mon Aug 12 23:07:07 CEST 2002
In article <mailman.1028921057.13158.python-list at python.org>,
Jeff Epler <jepler at unpythonic.net> wrote:
>...the slave must be within the same toplevel as the master...
Thank you very much. It had not occurred to me to look in the Tk man
pages or try wish. Documentation talks about "reparenting", but I
suspect this is purely a Toplevel level thing.
I'm using a special subclass of Toplevel that is nicely integrated into
my prefs system (part of my Python utilities
http://www.astro.washington.edu/owen/). It opens up at the desired size
and location and updates the preferences as necessary. it is also told
whether a window can be grown in X or Y. For this all to work, the
widget should be passed in while the special subclass of Toplevel is
Thus I would find it handy to be able to first create the widget, then
hand it to my Toplevel-ish thing.
Instead, I've been passing in a callback function that creates the
widget on demand. The Toplevel calls this once in __init__. This is a
rather ugly solution, since:
- If the user wants access to the widget, the user has to ask the
Toplevel for it.
- It's not obvious to a user when or where the callback will be called.
Will only one widget be created? When can the user safely get hold of a
copy of it? Yes one can document this, but it isn't a very normal use
- One has to create the callback function (not so bad using a good
GenericCallback class, but still an unpleasant extra step).
Any hints how to solve this better would be much appreciated.
More information about the Python-list