views:

39

answers:

1

So I need to be able to open several images in a grid layout and click on the images to perform various actions. Right now I am adding the images to a grid sizer. How do I capture mouse events from a sizer? Or should I display the images in another way to make it easy to respond to mouse events?

A: 

Bind one of the mouse events to your images

eg.

your_staticBitmap_object.bind(wx.EVT_LEFT_UP, self.onImageClick, your_staticBitmap_object)
volting
What should the type of your_image_object be here? Would it be wx.Image or wx.StaticBitmap or something else?
Johnny
Bind it your wx.StaticBitmap...
volting
Great thanks it works. The problem now is I don't know how to determine which Image triggered the event in the handler- GetEventSource returns the parent frame, not the image.
Johnny
Easy, just call GetId() on the event in the handler and compare it to the ID's of your staticBitmaps. If you want an example let me know and Ill add it to the my answer.
volting
and dont forget you can vote up my answer if your happy with it, which I assume are since you accepted it :P
volting