I broke it. Will fix early next week.
Matt On Thu, Jun 06, 2002 at 02:10:03PM -0500, Art Haas wrote: > Hi. > > The latest pygtk2 has lost the 'area' field in expose events. Here's > the warning that now pops up when I run a drawing example program > I have ... > > File "win8.py", line 472, in expose_event > area = event.area > AttributeError: 'gtk.gdk.EventExpose' object has no attribute > 'area' > > The code is the handler for an expose_event in a drawing area ... > > def expose_event(widget, event): > global pixmap > area = event.area > gc = widget.get_style().fg_gc[gtk.STATE_NORMAL] > win = widget.window > win.draw_drawable(gc, pixmap, area[0], area[1], > area[0], area[1], area[2], area[3]) > return gtk.FALSE > > A CVS update today has pulled in the following changes which seem > like the likely cause ... > > 2002-06-03 Matt Wilson <[EMAIL PROTECTED]> > > * gtk/gdk-types.defs (EventExpose): added to make the code > generator write GdkEventExpose * for > _wrap_gtk_container_propagate_expose (gets rid of a warning) > > I tried adding the appropriate "fields" bits to the scheme code > in the hope that their addition would fix the problem, but the > resulting python module segfaulted immediately, so my efforts > were a failure. :-( > > Below is a hacked-up version of the "scribble.py" script > found in the examples/simple directory that I made run under > pygtk2. It demonstrates the warning. Feel free to swap out > the existing scribble.py script which is more for the older > pygtk release with mine if you want. > > ========================================= > #!/usr/bin/env python > > #this is a simple translation of the scribble example that comes with GTK+ > > import gtk > > pixmap = None > > def configure_event(widget, event): > global pixmap > win = widget.window > width = win.get_geometry()[2] > height = win.get_geometry()[3] > pixmap = gtk.gdk.Pixmap(win, width, height, -1) > pixmap.draw_rectangle(widget.get_style().white_gc, gtk.TRUE, > 0, 0, width, height) > return gtk.TRUE > > def expose_event(widget, event): > area = event.area > gc = widget.get_style().fg_gc[gtk.STATE_NORMAL] > win = widget.window > win.draw_drawable(gc, pixmap, area[0], area[1], area[0], > area[1], area[2], area[3]) > return gtk.FALSE > > def draw_brush(widget, x, y): > rect = (x-5, y-5, 10, 10) > pixmap.draw_rectangle(widget.get_style().black_gc, gtk.TRUE, > x-5, y-5, 10, 10) > widget.queue_draw() > > def button_press_event(widget, event): > if event.button == 1 and pixmap != None: > draw_brush(widget, event.x, event.y) > return gtk.TRUE > > def motion_notify_event(widget, event): > if event.is_hint: > x, y, state = event.window.get_pointer() > else: > x = event.x; y = event.y > state = event.state > if state & gtk.gdk.BUTTON1_MASK and pixmap != None: > draw_brush(widget, x, y) > return gtk.TRUE > > def main(): > win = gtk.Window() > win.set_title('Test Input') > win.connect('destroy', lambda win: gtk.main_quit()) > win.set_border_width(5) > > vbox = gtk.VBox(spacing=3) > win.add(vbox) > vbox.show() > > drawing_area = gtk.DrawingArea() > drawing_area.set_size_request(200, 200) > vbox.pack_start(drawing_area) > drawing_area.show() > > drawing_area.connect("expose_event", expose_event) > drawing_area.connect("configure_event", configure_event) > drawing_area.connect("motion_notify_event", motion_notify_event) > drawing_area.connect("button_press_event", button_press_event) > drawing_area.set_events(gtk.gdk.EXPOSURE_MASK | > gtk.gdk.LEAVE_NOTIFY_MASK | > gtk.gdk.BUTTON_PRESS_MASK | > gtk.gdk.POINTER_MOTION_MASK | > gtk.gdk.POINTER_MOTION_HINT_MASK) > > button = gtk.Button("Quit") > vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE) > button.connect("clicked", lambda widget, win=win: win.destroy()) > button.show() > win.show() > gtk.main() > > if __name__ == '__main__': > main() > ===================================================== > > Thanks for all the work on PyGTK. > > -- > They that can give up essential liberty to obtain a little temporary > safety deserve neither liberty nor safety. > -- Benjamin Franklin, Historical Review of Pennsylvania, 1759 > _______________________________________________ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/