mouseEvent for my own object

Hi!

I’m a rookie in wx.Python, I do some code slowly but safely to learn :stuck_out_tongue:

And today I want to Bind my object (I’ve call i.e “truc”) to a mouse event.
but : “AttributeError: ‘truc’ object has no attribute ‘Bind’”… grrrr!

It’s means I must create a Bind attribute in my object? How???

Perhaps a explaination of the event mechanism will be welcome :wink:

Thanks !

Hi,

Hi!

I'm a rookie in wx.Python, I do some code slowly but safely to learn :stuck_out_tongue:

And today I want to Bind my object (I've call i.e "truc") to a mouse event.
but : "AttributeError: 'truc' object has no attribute 'Bind'".... grrrr!

It's means I must create a Bind attribute in my object? How???

Perhaps a explaination of the event mechanism will be welcome :wink:

Is you 'truc' object inherits from the GUI wxPython object or it is a
basic Python object?

Thank you.

···

On Thu, Apr 30, 2015 at 6:37 AM, Anthony Grolleau <grolleau.anthony@orange.fr> wrote:

Thanks !

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony Grolleau wrote:

And today I want to Bind my object (I've call i.e "truc") to a mouse
event.
but : "AttributeError: 'truc' object has no attribute 'Bind'".... grrrr!

It's means I must create a Bind attribute in my object? How???

Perhaps a explaination of the event mechanism will be welcome :wink:

You need to remember there are two objects involved. There is a
wx-based object that will be receiving the message, and there is the
object that you want to be called when the message arrives.

I assume you want a method in "truc" called when some frame gets a mouse
message. Yes? In that case, you call Bind on the object that will be
receiving the event (like a frame or a button). You pass the "truc"
object method as the callback. For example, if this is in the __init__
for your wxFrame:
        self.Bind( wx.EVT_LEFT_DOWN, truc.OnMouseMotion )

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.