I found the same thing shortly after posting my example. I discovered the answer a couple days later. The email should be in the archives, written by me on Apr 18 2002, labelled "Not bug..."
Here's the text of that message:
At least, not a pygnome/pygtk bug.
What seems to be happening is a conflict between entering & leaving my
line and the circle. Because the line is on top of the circle, it will
override the circle in regards to mouseovers (enter/leave).
When you mouse over the circle, I draw the line. The line is on top, and
if you happen to be mousing over where the line is, then you leave the
circle and enter the line. When you leave the circle, the leave
notification turns off the line, and you enter the circle again.
This seems to be where it's getting stuck.
I fixed it by simply creating the line, then the circle, so the line is
beneath the circle. Now it seems to work perfectly, as the line never
obstructs the circle.
So if you want to use the demo I posted, just reverse the order of
line/ellipse creation.
cf
On Sun, 2004-01-04 at 04:57, Doug Blanding wrote:
> In looking through the archive for topics related to using the gnome canvas, I
> came accross an example submitted by Colin Fox back in Apr 2002. I updated
> the syntax of the example to work under the more recent version of pygtk and
> have appended it below. The example runs, but it doesn't seem to run
> correctly. The canvas starts out responding to enter_notify and leave_notify
> events, but then freezes after a few such events. The canvas also freezes if
> the mouse is clicked over the object. Is this caused by a bug in the example
> or is there a bug in the canvas?
> --Doug Blanding
>
> #!/usr/bin/env python
>
> import gtk
> import gnome.canvas
>
> class WorldObject:
> def __init__(self,canvas,x,y):
> self.myobj = None
> self.myline = None
> self.mylinepoints = [x,y,x,y]
> self.canvas = canvas
> self.width = 20
> self.height = 20
> self.x = x
> self.y = y
> self.lmb_pressed = 0
> self.build()
>
> def set_line_endpoint(self,x,y):
> self.mylinepoints[2] = x
> self.mylinepoints[3] = y
> self.myline.set(points=self.mylinepoints)
>
> def item_event(self, widget, event=None):
> if event.type == gtk.gdk.BUTTON_RELEASE:
> if event.button == 1:
> self.lmb_pressed = 0
> self.myline.hide()
> return gtk.TRUE
>
> elif event.type == gtk.gdk.BUTTON_PRESS:
> if event.button == 1:
> self.lmb_pressed = 1
> self.set_line_endpoint(event.x,event.y)
> self.myline.show()
> return gtk.TRUE
>
> elif event.type == gtk.gdk.MOTION_NOTIFY:
> if event.state & gtk.gdk.BUTTON1_MASK:
> self.set_line_endpoint(event.x, event.y)
> return gtk.TRUE
>
> elif event.type == gtk.gdk.ENTER_NOTIFY:
> # Make the outline wide, show the arrow
> widget.set(width_units=3, fill_color="cyan")
> self.myline.show()
> return gtk.TRUE
>
> elif event.type == gtk.gdk.LEAVE_NOTIFY:
> # Make the outline thin, hide the arrow
> widget.set(width_units=1, fill_color="blue")
> if self.lmb_pressed == 0:
> self.myline.hide()
> return gtk.TRUE
>
> return gtk.FALSE
>
>
> def build(self):
> self.myobj = self.canvas.root().add('GnomeCanvasEllipse',
> x1=self.x-(self.width/2),
> y1=self.y-(self.height/2),
> x2=self.x+(self.width/2),
> y2=self.y+(self.height/2),
> fill_color='blue', outline_color='black',
> width_units=1.0)
>
> self.myline = self.canvas.root().add('GnomeCanvasLine',
> points=self.mylinepoints,
> width_units=1.0,
> line_style='GDK_LINE_ON_OFF_DASH',
> arrow_shape_a=10.0,
> arrow_shape_b=15.0,
> arrow_shape_c=5.0,
> first_arrowhead=gtk.FALSE,
> last_arrowhead=gtk.TRUE,
> fill_color='black')
>
> self.myline.hide()
> self.myobj.show()
> self.myobj.connect("event",self.item_event)
>
>
> class SimpleTest:
> def __init__(self):
> self.width = 400
> self.height = 400
> self.canvas = None
>
> def populate(self):
> self.element = WorldObject(self.canvas,200,200)
>
> def open_window(self):
> win = gtk.Window()
> win.connect('destroy', gtk.mainquit)
> win.set_title('Simple Example')
>
> self.canvas = gnome.canvas.Canvas()
> self.canvas.set_size_request(self.width, self.height)
> self.canvas.set_scroll_region(0,0, self.width, self.height)
> win.add(self.canvas)
> self.canvas.show()
> win.show()
>
> if __name__ == '__main__':
> st = SimpleTest()
> st.open_window()
> st.populate()
> gtk.mainloop()
>
> _______________________________________________
> pygtk mailing list [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
Colin Fox <[EMAIL PROTECTED]>
CF Consulting Inc.
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
