#!/usr/bin/env python

# Demonstrate the spurious expose event bug in pygtk.

import gtk

drawing_area = 0

def expose_event(widget, event) :
    global gc
    print "Expose:", event.type
    print "position:", event.area.x, event.area.y,
    print "area:", event.area.width, event.area.height
    return True

def main() :
    global drawing_area

    win = gtk.Window()
    win.set_name("PyGtk Test")
    win.connect("destroy", gtk.main_quit)

    vbox = gtk.VBox(spacing=3)
    win.add(vbox)
    vbox.show()

    drawing_area = gtk.DrawingArea()
    drawing_area.set_size_request(100, 100)
    vbox.pack_start(drawing_area)
    drawing_area.show()

    drawing_area.set_flags(gtk.CAN_FOCUS)

    drawing_area.set_events(gtk.gdk.EXPOSURE_MASK |
                            gtk.gdk.KEY_PRESS_MASK |
                            gtk.gdk.BUTTON_PRESS_MASK )

    drawing_area.connect("expose-event", expose_event)

    button = gtk.Button("Quit")
    vbox.pack_start(button, expand=False, fill=False)
    button.connect("clicked", lambda widget, win=win: win.destroy())
    button.show()

    win.show()
    gtk.main()

if __name__ == '__main__':
    main()

