removing "close" button in Tkinter

Randall Hopper aa8vb at yahoo.com
Tue May 16 15:48:25 CEST 2000


Thomas Lane:
 |I'm trying to write a Tkinter program that has the maximize and minimize
 |buttons in the upper-right corner of the window, but I don't want the
 |close button. Does anyone know how to hide/remove this button from a
 |"TopLevel" window?

These window control icons are implemented by the window manager not your
application.  Besides reconfiguring your window manager (I see you're on
WinNT so that's probably not an option), look at using what area called
"override redirect" windows.  In X, override redirect says to the window
manager "don't manage this window; I'm taking care of it myself".  (I don't
know what this does on the WinNT version of Tk though.)

Or, rather than find some way to remove the button, you may be able to just
ignore it by setting a DELETE_WINDOW callback that ignores the close event:

   def __CancelCommand(event=None): pass
   self.top.protocol( 'WM_DELETE_WINDOW', __CancelCommand )

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list