wxShapeEvtHandler

    def OnMotion(self, event):
        #shape = self.evtHandler.GetShape()
        shape = self.FindShape(event.GetX(), event.GetY())
        if shape is not 0:
            shape.GetX()
        event.Skip()

AFAIK, OnMotion() doesn't exist in wxShapeEvtHandler...
Supposing that you have a wxShapeCanvas you could do :

class MyShapeCanvas(wx.ShapeCanvas):

    def __init__(self, parent):
        wx.ShapeCanvas.__init__(self, parent)
        ... etc
        wx.EVT_MOTION(self, self.OnMotion)
        ... etc

    def OnMotion(self, event):
        x, y = event.GetPosition()
        s = self.FindShape(x, y)
        if s is not None:
            print '>> Mouse is over %s' % str(s)
        event.Skip()

    # method overriden
    def FindShape(self, x, y):
        for s in self.GetShapeList():
            if s.HitTest(x, y)[0]:
                return s
        return None

···

--
David <izi@club-internet.fr>

So if you didn't override the FindShape method (as I did in my
example), you're probably getting a tuple containing the shape and its
nearest attachment point... so the right code is:

Tanks! That helps a lot! Didn't see that I was getting a tuple...

BTW: In which file can I find the source code for wxShapeEvtHandler? Would
be nice to have a look at it when overriding its methods.

Thomas

cd wxPython grep -r wxShapeEvtHandler *

Should get you going :wink: I am not having a go at you but as a tech support type,
I have found that where a large number of questions can get answered "google is
your friend", an equally large number in programming can get answered by "grep
is your friend" :slight_smile: In fact, not much can't be answered by the two in combination
LOL :slight_smile:

When I did it I found a large number of references in the wxPython/contrib/ogl
directory. I did not look to see if there are any in wxWindows itself. Try grepping
higher up the CVS tree!

HTH

MarkL

···

On Tue, 9 Sep 2003 13:38:11 +0200 Thomas Aanensen <thoaan@stud.cs.uit.no> wrote:

BTW: In which file can I find the source code for wxShapeEvtHandler? Would
be nice to have a look at it when overriding its methods.