On Sun, 2005-20-03 at 11:09 -0300, Eric Jardim wrote:
> >>>>>>>>
>
> import gtk
> import gtk.gdk as gdk
>
> def quit(data=None):
> gtk.main_quit()
>
> def window_event(window, event):
> state = event.new_window_state
> if state == 0:
> window.set_title('Normal')
> elif state == gdk.WINDOW_STATE_ICONIFIED:
> window.set_title('Iconified')
> elif state == gdk.WINDOW_STATE_MAXIMIZED:
> window.set_title('Maximized')
>
> window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> window.connect('destroy', quit)
> window.connect('window-state-event', window_event)
> window.set_title('Normal')
> window.show()
> gtk.main()
>
> <<<<<<<<
> Hope helped,
>
> [Eric Jardim]
This code does not always work as expected. This is due to the
new_window_state and changed_mask possibly having more than one flag
attached. The event.new_window_state and event.changed_mask are
enumerated data types.
Here is an example of the event.new_window_state passed to the callback
function: (actual debug print of event.new_window_state)
<flags GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_MAXIMIZED of type
GdkWindowState>
So far I have not found out how to properly look for a specific flag
when there are more than one. I have found this doc
http://www.python.org/workshops/1994-11/BuiltInClasses/BuiltInClasses_5.html
which describes how to integrate CType structures into python. It is seems too
terse for my understanding though.
I have got some code working (so far) using the change_mask which so far
is only passing one flag, but in the docs it states that it too can have
combinations of flags.
[quote]
"changed_mask" Read/Write The mask specifying what flags have changed - a
combination of:...[snip]
[/quote]
working code:
def new_window_state(self, widget, event):
"""set the minimized variable to change the title to the same as the
statusbar text"""
dprint(event.new_window_state) # debug print statements
dprint(event.changed_mask)
if event.changed_mask == gtk.gdk.WINDOW_STATE_ICONIFIED:
if not self.minimized:
dprint("TERMINAL: new_window_state; event = minimized")
self.minimized = True
self.window.set_title(self.status_text)
else: # self.minimized:
dprint("TERMINAL: new_window_state; event = unminimized")
self.minimized = False
self.window.set_title(self.title)
return False
A potential problem with this code is if the self.minimized variable
gets out of sync with the actual window state.
Anyone know how to do correctly?
--
Brian <[EMAIL PROTECTED]>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/