Thanks Robin, it’s dunn:-)
I have used custom events and it’s working fine. Just need to know one more thing. Is it possible to hook “Rectangle” object to events by using
custom events. Although I have found an another way to bind custom shapes to events but it would be much better if we can use custom event
mechanism.
Suggest me If It could be dunn.
Prashant
Demo.py (1.6 KB)
MagicCanvas.py (11.8 KB)
···
----- Original Message ----
From: Robin Dunn robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Sent: Tuesday, 30 September, 2008 9:14:26 AM
Subject: Re: [wxpython-users] Event order, class vs instances
Prashant
Saxena wrote:
When you have an event in the class and same event you are binding when
creating an instance of it, the order of execution of events are: first
instance then class.Take a look the example:
1.Run Demo.py
2.Left down on rectangle and ‘None’ is getting printed.It’s because first LEFT_DOWN event of instance mCanvas is getting fired
and then LEFT_DOWN of class,
In your example there is no difference, both of the Bind()'s are being
made on the instance. It’s just that in one place the instance is
referenced with ‘self’ and in the other place it is referenced with
‘self.mCanvas’ but they are really both referring to the same object.
which will set value of ‘selectedObject’
attribute. I need to switch the order of events to get the correct
results or How do I solve this
problem?
Reverse the order of the Bind() calls. Or write your event handlers
such that they do not depend on the order of the event handlers being
called. Or have your MagicCanvas.OnLeftMouseDown handler generate a
custom event and then catch that one in the container rather than the
canvas’s EVT_LEFT_DOWN.
–
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Connect with friends all over the world. Get Yahoo! India Messenger.