Cliff - the problem is that on my computer, the line:
EVT_MOUSEWHEEL(self.bitmap, self.OnM)
doesn't catch any events... the function self.OnM is never called,
while
the line:
Hm. Must be something with the Win32 libs. It works fine on GTK+.
EVT_MOUSEWHEEL(self, self.OnM)
does catch the events for the frame.
Robin - I'm using Python 2.2 with wxPython 2.3.3.1 under winXP. I will
try making my own control for displaying a bitmap (its good practice
:D), could you - in a few lines - describe how I would do that? For
example, I assume I need to derive an object from wxWindow, wxControl,
wxObject and wxEvtHandler (like wxStaticBitmap is), but after that I
don't know where to go with it...
Try this:
from wxPython.wx import *
class BitmapPanel(wxPanel):
def __init__(self, parent, id, bitmap):
wxPanel.__init__(self, parent, id,
size = (bitmap.GetWidth(), bitmap.GetHeight()))
self.bitmap = bitmap
EVT_PAINT(self, self.OnPaint)
def Draw(self, dc):
dc.DrawBitmap(self.bitmap, 0, 0)
def OnPaint(self, event):
dc = wxPaintDC(self)
self.Draw(dc)
class MyFrame(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, id, title,
wxPoint(100, 100), wxSize(500, 400))
EVT_CLOSE(self, self.OnCloseWindow)
self.panel = wxPanel(self, -1)
self.bitmap = BitmapPanel(self.panel, -1,
bitmap =
wxBitmap('/usr/share/pixmaps/XMMS1.png'))
# EVT_MOUSEWHEEL(self, self.OnM)
EVT_MOUSEWHEEL(self.bitmap, self.OnM)
def OnCloseWindow(self, event):
self.Destroy()
def OnM(self, event):
print event
# print GetWheelRotation()
class MyApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
self.frame = MyFrame(None, -1, "TITLE")
self.frame.Show(true)
self.SetTopWindow(self.frame)
return true
app = MyApp(0)
app.MainLoop()
···
On Thu, 2003-01-02 at 04:08, Amos Joshua wrote:
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308