tkinter: is there a way to switch a widget's master?

Frederic Rentsch anthra.norell at bluewin.ch
Mon May 14 14:02:23 EDT 2012


Hi there,

I would like to prepare a bunch of info text widgets to be displayed in
Toplevel windows at the user's command (when ever he needs directions).
I know how to remove and restore widgets without destroying them in
between. The problem with a Toplevel is that it is a master that comes
and goes, of a Text that is supposed to stay as long as the program
runs. (Building the Text involves reading a file and compiling lots of
edited-in formatting symbols. Repeating this every time the Toplevel is
called seems rather inelegant.) 

toplevel = Toplevel (root, ...)
info_text = MyText (toplevel, ...)
info_text.pack ()
# No problem, except for the inelegant remake of the text on every call.

I tried:

text = MyText (root, ...)
# Later, on user demand
toplevel = Toplevel (root, ...)
info_text.lower (belowThis = toplevel)
info_text.pack ()

This doesn't work! toplevel is empty and text appears in the root
window. Is there a way to switch a widget's master?

Thanks for comments

Frederic







More information about the Python-list mailing list