>>>>> "lg" == lg <[EMAIL PROTECTED]> writes:
lg> Hey Boys, I'm having problems with the Get the coordinate(x,y)
lg> in the drawing_area,
I assume you want to know where the mouse is. You can either get the
coordinate of a mouse click or a mouse motion. The approach is the
same.
1) register to listen for click or motion events
2) handle them
At a minimum, I usually connect to the following events for my drawing
area
self.connect('key_press_event', self.key_press_event)
self.connect('key_release_event', self.key_release_event)
self.connect('expose_event', self.expose_event)
self.connect('configure_event', self.configure_event)
self.connect('realize', self.realize)
self.connect('motion_notify_event', self.motion_notify_event)
self.connect('button_press_event', self.button_press_event)
self.connect('button_release_event', self.button_release_event)
self.set_events(
gdk.KEY_PRESS_MASK|
gdk.KEY_RELEASE_MASK|
gdk.EXPOSURE_MASK |
gdk.LEAVE_NOTIFY_MASK |
gdk.BUTTON_PRESS_MASK |
gdk.BUTTON_RELEASE_MASK |
gdk.POINTER_MOTION_MASK )
where self is an instance of a class derived from gtk.DrawingArea.
You then need to define these functions. Eg, for button_press
def button_press_event(self, widget, event):
win = widget.window
if event.button==3:
pass # do something
elif event.button==1:
pass # do something with event.x and event.y
return gtk.TRUE
Notice how event.button carries information about which button was
pressed and event.x and event.y give you the x and y coords.
For mouse motion, you simply need to define something like
def motion_notify_event(self, widget, event):
print event.x, event.y,
return gtk.TRUE
That's it!
JDH
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/