[wxPython] Mouse events in an OGL application

Hopefully one of you will have some time to look at the code
that follows. I don't understand why only the first rectangle
responds to a dragging event.
What is missing?

I'm no expert - this was the first wxOGL code I've looked at - so this could be completelyt wrong, but you need to use

        aShape = wxDrawnShape()
        aShape.SetX(200)
        aShape.SetY(200)
        aShape.DrawRectangle(wxRect(-50, -40, 100, 80))
        aShape.CalculateSize()

The wxDrawnShape is initially located at the origin. You need SetX and SetY to locate it at (200, 200), just like you did for the wxRectangleShape.

The DrawRectangle just defines what to draw, not the bounding box. CalculateSize() calculates the bounding box correctly. And you need to use an origin of (-50, -40) for the rectangle, as the origin of the wxDrawnShape seems to be at the centre...

I've tested the above and it *seems* to work. But it feels like black magic. I'm sure someone who actually understands this better than me can provide an explanation of why it works...

Paul

···

From: Alban Kulla [mailto:a_kulla@hotmail.com]