Note that there are some explanatory texts on larger screens.

plurals
  1. POwxPython Mouse Entering/Leaving event methods don't work on Linux
    primarykey
    data
    text
    <p>I am trying to provide a custom button class that needs a hover for it to work properly. I am therefore using StaticBitmap and extending it. But I am finding differences between Windows and Linux using the same exact code between both. The following small simple example doesn't work properly in Linux, but works fine in Windows:</p> <pre><code>import wx class MyForm(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "Test") panel = wx.Panel(self, wx.ID_ANY, size=(200,100)) panel.SetBackgroundColour("Black") # create a normal bitmap button bitmap = wx.Bitmap("images/power.png", wx.BITMAP_TYPE_ANY) self.image1 = wx.StaticBitmap(panel, bitmap=bitmap, size=bitmap.GetSize()) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.image1) panel.SetSizer(sizer) # This works on Windows, but not on Linux #self.image1.Bind(wx.EVT_ENTER_WINDOW, self.OnHover) #self.image1.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveHover) # This (used by itself) gets events for both Linux/Win, but # doesn't find e.Entering() or e.Leaving() on Linux! self.image1.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents) def OnHover(self, e): print "Hover" def OnLeaveHover(self,e): print "Leaving Hover" def OnMouseEvents(self,e): print "Mouse event" #print dir(e) if e.Entering(): print "Hover" elif e.Leaving(): print "Leaving Hover" else: e.Skip() if __name__ == "__main__": app = wx.App(False) frame = MyForm() frame.Show() app.MainLoop() </code></pre> <p>Is this a known issue? Is there some other way to bind the event to get the mouseover/hover operation to work properly in Linux?</p> <p>Also, no forms of <code>self.Bind()</code> work here on Linux or Windows. Why? i.e.:</p> <pre><code>self.Bind(wx.EVT_ENTER_WINDOW, self.OnHover, self.image1) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveHover, self.image1) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload