I see from some old conversations the wx.StaticBitmap does not capture
mouse events. If I put images in a panel and bind the mouse events to
the panel, they still don't work when I click on the image. Do I have
to use OGL to get this to work? Orl would a series of Bitmap Buttons
do the trick? These seem like overkill for what appears to be a simple
problem.
WindowsXP
Python 2.6
wxPython 2.8.9.1
BaffleProblem.py (3.54 KB)
···
--
Josh English
Joshua.R.English@gmail.com
http://joshenglish.livejournal.com
Hi Josh,
I see from some old conversations the wx.StaticBitmap does not capture
mouse events. If I put images in a panel and bind the mouse events to
the panel, they still don't work when I click on the image. Do I have
to use OGL to get this to work? Orl would a series of Bitmap Buttons
do the trick? These seem like overkill for what appears to be a simple
problem.
When thinking about static controls (static text, static bitmap) and
their events, always look for their generic version (implemented in
pure Python). In this case, you might want to look at wx.lib.statbmp.
HTH.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
···
On Sat, Jan 24, 2009 at 7:40 PM, Josh English wrote:
I see from some old conversations the wx.StaticBitmap does not capture
mouse events. If I put images in a panel and bind the mouse events to
the panel, they still don’t work when I click on the image. Do I have
to use OGL to get this to work? Orl would a series of Bitmap Buttons
do the trick? These seem like overkill for what appears to be a simple
problem.
Your image is still a StaticBitmap – which doesn’t capture events. That you are placing the StaticBitmap on a panel doesn’t change that, really.
You can make an image panel very simply with:
class NotStaticImage(wx.Panel):
def init(self, parent, bmp):
wx.Panel.init(self, parent, -1, size=(bmp.GetWidth(), bmp.GetHeight))
self._bmp = bmp
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
dc = wx.AutoBufferedPaintDC()
dc.DrawBitmap(self._bmp, 0, 0)
Then you just catch the mouse events off of that panel directly.
–Stephen