Can you change a Tkinter widget's master?

sternber at socrates.Berkeley.EDU sternber at socrates.Berkeley.EDU
Mon May 14 17:01:41 CEST 2001


In article <3OdL6.1703$Yu6.423611 at newsc.telia.net>,
Fredrik Lundh <fredrik at effbot.org> wrote:
>Theodore D. Sternberg wrote:
>> In Tkinter, is there any way to change a widget's master?  Assigning to
>> the master attribute doesn't seem to have any effect.
>
>nope.  widgets are bound to their parent (master) when they're
>created.  assigning to the master attribute will only mess up the
>internal structures...
>
>> Setting (or resetting) the master would be the key to true compound widgets.
>> For example, you could subclass Frame to take as constructor arguments several
>> widgets (of any kind) and arrange them in some given way.
>
>you can use template classes, which can be composed freely,
>and which creates the real widgets on demand.  an example:
>
>    dialog = Dialog(
>        Label(text="enter your name"),
>        Entry(width=20, name="name"),
>        ButtonBox(
>            Button(text="OK", command=self.ok),
>            Button(text="Cancel", command=self.cancel)
>            )
>        )
>    result = dialog.display()
>    if result:
>        print result.name
>
>(this is from an unpublished corner of Tkinter 3000)

The problem is that the Label, Entry and ButtonBox won't have dialog
as their master.  Their master will be '.'.  And so it won't be possible
to arrange them inside dialog, which was my goal.


>
>Cheers /F
>
>





More information about the Python-list mailing list