I've been searching for information on the following Tkinter window features without success. Platform is Windows, Python 2.7. At the end of this post is code that can be used to explore Tkinter window events.
How can one detect window minimize/maximize events? The event object returned by binding to a window's event does contain any information about these events. I've searched for protocols (like WM_DELETE_WINDOW) that might expose these events without success.
How can one determine window frame border sizes (not Tkinter frames, the frame the OS places around the container where Tkinter places its widgets)? Is there a non-platform specific way to discover these windows properties or do I need to use platform specific solutions like the win32 api under Windows?
How can one determine a window's visibility, eg. whether a window is invisible or not as set by .withdraw()?
Is it possible to cancel a window event, eg. if one wanted to constrain a window to a certain location on a user's desktop? Returning 'break' from a window's event does not cancel window move or resize events.
Here's sample code for experimenting with Tkinter window events.
def onFormEvent( event ):
for key in dir( event ):
if not key.startswith( '_' ):
print '%s=%s' % ( key, getattr( event, key ) )
print
import Tkinter as tkinter
root = tkinter.Tk()
lblText = tkinter.Label( root, text='Form event tester' )
lblText.pack()
root.bind( '<Configure>', onFormEvent )
root.mainloop()
Update: Here's what I learned about the following events:
event.type == 22 (one or more of following changed: width, height, x, y)
event.type == 18 (minimized) event.widget.winfo_viewable() = 0 (invisible)
event.type == 19 (restore after minimized)
event.type == 2 (maximize)
event.type == 22 (restore after maximized due to change in width and height)