[pygtk] visibility-notify problem?

Michel NF michel4j at gmail.com
Sun Apr 15 04:47:29 WST 2007


Hi Everyone,
I'm having some problems getting visibility-notify events from a drawing
area. 
The problem is that the "visibility-notify-event" is not emitted by the
drawing area when the notebook page is switched such that the drawing
area becomes obscured by a different page. But it is emitted when it
becomes visible again. 

Is this a feature or a bug. It works as expected when the "other" window
is a different application, but does not work when obscured by another
notebook page.

The Code snippet below illustrates this:

#!/usr/bin/env python

import gtk, gobject

def on_visibility_notify(widget,event):
	print info, event.state
	return True
	
def main():
	win = gtk.Window()
	win.set_size_request(200,200)
	win.connect("destroy", lambda x: gtk.main_quit())
	book = gtk.Notebook()

	da = gtk.DrawingArea()
	da.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
	im = gtk.Image()
		
	book.append_page( da, tab_label=gtk.Label('Drawing Area') )
	book.append_page( im, tab_label=gtk.Label('Image') )

	da.connect('visibility-notify-event', on_visibility_notify)

	win.add(book)
	win.show_all()

	gtk.main()


if __name__ == '__main__':
	main()




More information about the pygtk mailing list