pyGTK on Mouse over event ?

D

Domenique.Tilleuil

hello,

Is there an event simular to the java event onMouseOver ?
I want to get the coordinates of the mouse pointer when it is over an
image ( GTKImage widget)

I've tried using the EventBox with the motion_notify but that only
seems to work when the mouse is pressed ?
 
T

tiissa

hello,

Is there an event simular to the java event onMouseOver ?
I want to get the coordinates of the mouse pointer when it is over an
image ( GTKImage widget)

I've tried using the EventBox with the motion_notify but that only
seems to work when the mouse is pressed ?
Why do you use an event box?
Image derives from Widget hence can be connected to the
motion-notify-event just like EventBox. Did you try directly?
 
D

Domenique.Tilleuil

if i add a motion_notify or even a butten_press event to an image
object it does absolutly nothing :s
 
T

tiissa

if i add a motion_notify or even a butten_press event to an image
object it does absolutly nothing :s
I have tried coding a simple application in pyGTK and I remember I had
trouble getting button_press event in a DrawingArea.
I was using glade and despite having declared a handler to this event, I
had to manually call add_events(gtk.gdk.BUTTON_PRESS_MASK) (the connect
was ok but the event mask was not).
Have you checked this?
 
D

Domenique.Tilleuil

def __init__(self):
xml = gtk.glade.XML("/home/domenique/project1.glade")
self.window = xml.get_widget("window1")
self.img = xml.get_widget("image1")
self.img.set_from_file("./test.svg")
self.img.show()
self.img.add_events(gtk.gdk.BUTTON_MOTION_MASK)
xml.signal_autoconnect({
'on_window1_delete_event': self.on_window1_delete_event,
'on_window1_destroy_event': self.on_window1_destroy_event,
'on_image1_motion_notify_event': self.on_image1_motion_notify_event,
'on_image1_button_press_event': self.img_key_press,
})

This is the code so far. i've added the MOTION MASK to the image
widget, is that what u ment ?
 
T

tiissa

def __init__(self):
xml = gtk.glade.XML("/home/domenique/project1.glade")
self.window = xml.get_widget("window1")
self.img = xml.get_widget("image1")
self.img.set_from_file("./test.svg")
self.img.show()
self.img.add_events(gtk.gdk.BUTTON_MOTION_MASK)
xml.signal_autoconnect({
'on_window1_delete_event': self.on_window1_delete_event,
'on_window1_destroy_event': self.on_window1_destroy_event,
'on_image1_motion_notify_event': self.on_image1_motion_notify_event,
'on_image1_button_press_event': self.img_key_press,
})

This is the code so far. i've added the MOTION MASK to the image
widget, is that what u ment ?
Yes.
But I guess by your question it doesn't work better than before. Sorry I
didn't help much. :/
 
D

Domenique.Tilleuil

no problem i'll just keep using the eventbox but is there an event wich
is triggert when the mouse moves over the eventbox ?
 
T

tiissa

def __init__(self):
xml = gtk.glade.XML("/home/domenique/project1.glade")
self.window = xml.get_widget("window1")
self.img = xml.get_widget("image1")
self.img.set_from_file("./test.svg")
self.img.show()
self.img.add_events(gtk.gdk.BUTTON_MOTION_MASK)
xml.signal_autoconnect({
'on_window1_delete_event': self.on_window1_delete_event,
'on_window1_destroy_event': self.on_window1_destroy_event,
'on_image1_motion_notify_event': self.on_image1_motion_notify_event,
'on_image1_button_press_event': self.img_key_press,
})

This is the code so far. i've added the MOTION MASK to the image
widget, is that what u ment ?
Actually I read too fast. I meant BUTTON_PRESS_MASK (not motion) for the
button_press_event.
For motion_notify_event, I guess it would be POINTER_MOTION_MASK (not
button).
 
D

Domenique.Tilleuil

the POINTER MOTION MASK doesn't do the trick either. This is the first
time i'm using python and pyGTK and it's really sad to see that a
simple mouseover is hard to program. :s
 
D

Domenique.Tilleuil

I've managed to get it all working !

I've used an Image inside an eventBox and used the motion notify event.
The trick was to add the Events in the Common tab of the Glade property
editor. Those where the MASK's you where talking about. Anyway, now it
works just fine :) Thx for the information and for pushing me into the
right direction :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top