Tkinter wm_withdraw doesn't work

Isaac To Kar Keung kkto at csis.hku.hk
Sun May 20 07:30:09 EDT 2001


>>>>> "Theodore" == Theodore D Sternberg <strnbrg at c532352-a.frmt1.sfba.home.com> writes:

    Theodore> root = Tk()
    Theodore> wm = Wm()
              ^^^^^^^^^

This is wrong conceptually.  Wm is not a class that is supposed to be
instantiated.  Instead, it is supposed to be used indirectly, to derive
other classes from it.  "Introduction to Tkinter" call such classes
"mixin's", classes to mix into other classes to provide extra
functionalities.  Only two classes directly derive from Wm, both because
they are top-level widgets.  One is Tk, the other is Dialog.  So to withdraw
the root window, all you need is:

  root = Tk()
  root.wm_withdraw()

The same holds for Dialogs.  That you can say "wm = Wm()" is just because
Python is a language that do not disallow silly things from happening, so
everybody should really read the (unluckily, non-existent) manual.  Since
it is currently impossible to read the manual, everybody should really read
the source.

Notably, every concrete widget class that is *not* a top-level widget class
is an internal class, and hence is derived from Widget to support the
packer, grid and placer operations.

Regards,
Isaac.




More information about the Python-list mailing list