I don't know much about wxPython, but the left/right mouse button events _ARE_ trapped, but not when clicking on the image, probably because they are registered to the panel not to the image. Just resize the window and click next to the image.
Hope this helps for now, before you get a response from someone who knows some more about wxPython (e.g. why the events from the bitmap are not forwarded to the panel containing it?). Claudio P.S. Here the corrected code I was able to run on my machine: import string import wx # import images import os import cStringIO import xml.sax from wxPython.wx import * # from Main import opj class DisplayPicture(wx.Frame): cD = 0 def __init__(self, parent, id, title, bmp, w, h): wxFrame.__init__(self, parent, wxID_ANY, title, size = ( w, h), style=wxDEFAULT_FRAME_STYLE ) mD = 0 self.Panel=wx.Panel(self) wx.StaticBitmap(self.Panel, -1, bmp, (5, 5) ) """ FOR SOME REASON THE MOUSE CLICKS DON-T WORK!""" """ SHIT SHIT SHIT SHIT ... x 1000 """ wx.EVT_LEFT_DOWN(self.Panel, self.OnLeftClick) wx.EVT_LEFT_UP(self.Panel, self.OnLeftClick) wx.EVT_LEFT_DCLICK(self.Panel, self.OnLeftClick) self.CreateStatusBar() self.Show() self.SetStatusText('Submap Coordinates:') def OnLeftClick(self, event): print "ok the mouse click works!" class MyApp(wx.App): cD = 0 def OnInit(self): wx.InitAllImageHandlers() return 1 # # Main # if __name__ == "__main__": app = MyApp(0) data = open('e:\winnt\Granit.bmp', "rb").read() stream = cStringIO.StringIO(data) bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) bmpW = bmp.GetWidth() bmpH = bmp.GetHeight() DisplayPicturePanel=DisplayPicture(None, -1, "Test MB", bmp, bmpW, bmpH) #MainFrame = DisplayPicture(None,-1,"Test Mouse Clicks") app.MainLoop() <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Hi, > > I have included a small listing. The test program opens a panel and > show a bitmap. > What I want is to when the mouse is over the bitmap panel, I want to > trap the left mouse click. > The purpose is to get the position of the mouse pointer on the bitmap. > However, for some reason, the left (I also tried right) mouse clicks > are not intercepted. > I new to Python and wxWindows so any help would be greatly appreciated. > > With kind regards, > > Kris > " > import string > import wx > import images > import os > import cStringIO > import xml.sax > > from wxPython.wx import * > from Main import opj > > class DisplayPicture(wx.Frame): > cD = 0 > > def __init__(self, parent, id, title, bmp, w, h): > wxFrame.__init__(self,parent,wxID_ANY, title, size = ( w, h), > style=wxDEFAULT_FRAME_STYLE) > > mD = 0 > > self.Panel=wx.Panel(self) > wx.StaticBitmap(self.Panel, -1, bmp, (5, 5) ) > > """ FOR SOME REASON THE MOUSE CLICKS DON'T WORK!""" > """ SHIT SHIT SHIT SHIT ... x 1000 """ > wx.EVT_LEFT_DOWN(self.Panel, self.OnLeftClick) > wx.EVT_LEFT_UP(self.Panel, self.OnLeftClick) > wx.EVT_LEFT_DCLICK(self.Panel, self.OnLeftClick) > > > self.CreateStatusBar() > self.Show() > > self.SetStatusText('Submap Coordinates:') > > def OnLeftClick(self, event): > print "ok the mouse click works!" > > class MyApp(wx.App): > cD = 0 > def OnInit(self): > wx.InitAllImageHandlers() > return 1 > > # > # Main > # > > if __name__ == "__main__": > app = MyApp(0) > > > data = open(opj('c:\winnt\Greenstone.bmp'), "rb").read() > stream = cStringIO.StringIO(data) > bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) > bmpW = bmp.GetWidth() > bmpH = bmp.GetHeight() > DisplayPicturePanel=DisplayPicture(None, -1, "Test MB", bmp, bmpW, > bmpH) > #MainFrame = DisplayPicture(None,-1,"Test Mouse Clicks") > > > app.MainLoop() > " > -- http://mail.python.org/mailman/listinfo/python-list