C
Chris Carlen
Hi:
#!/usr/bin/env python
"""From listing 3.3 in 'wxPython in Action'
Demonstrates that something funny happens when you click&hold in the
frame, then drag the mouse over the button window. The
wx.EVT_ENTER_WINDOW event is missed. The wx.EVT_LEAVE_WINDOW event is
NOT missed when you click&hold the mouse button over the button, and
leave the button window."""
import wx
class MouseEventFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, title="Listing 3.3",
size=(300, 100))
self.panel = wx.Panel(self)
self.button = wx.Button(self.panel, label="Not over", pos=(100,
15))
self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.button)
self.button.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
self.button.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
# This is not critical to demonstrating the 'bug', but just provides
# feedback that the wx.EVT_BUTTON events are working correctly
# in relation to entering/leaving the button window.
def OnButtonClick(self, event):
if self.panel.GetBackgroundColour() == "Green":
self.panel.SetBackgroundColour("Red")
else: self.panel.SetBackgroundColour("Green")
self.panel.Refresh()
def OnEnterWindow(self, event):
self.button.SetLabel("Over")
event.Skip()
def OnLeaveWindow(self, event):
self.button.SetLabel("Not over")
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MouseEventFrame(None, id=-1)
frame.Show()
app.MainLoop()
--
Good day!
________________________________________
Christopher R. Carlen
Principal Laser&Electronics Technologist
Sandia National Laboratories CA USA
(e-mail address removed)
NOTE, delete texts: "RemoveThis" and
"BOGUS" from email address to reply.
#!/usr/bin/env python
"""From listing 3.3 in 'wxPython in Action'
Demonstrates that something funny happens when you click&hold in the
frame, then drag the mouse over the button window. The
wx.EVT_ENTER_WINDOW event is missed. The wx.EVT_LEAVE_WINDOW event is
NOT missed when you click&hold the mouse button over the button, and
leave the button window."""
import wx
class MouseEventFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, title="Listing 3.3",
size=(300, 100))
self.panel = wx.Panel(self)
self.button = wx.Button(self.panel, label="Not over", pos=(100,
15))
self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.button)
self.button.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
self.button.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
# This is not critical to demonstrating the 'bug', but just provides
# feedback that the wx.EVT_BUTTON events are working correctly
# in relation to entering/leaving the button window.
def OnButtonClick(self, event):
if self.panel.GetBackgroundColour() == "Green":
self.panel.SetBackgroundColour("Red")
else: self.panel.SetBackgroundColour("Green")
self.panel.Refresh()
def OnEnterWindow(self, event):
self.button.SetLabel("Over")
event.Skip()
def OnLeaveWindow(self, event):
self.button.SetLabel("Not over")
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MouseEventFrame(None, id=-1)
frame.Show()
app.MainLoop()
--
Good day!
________________________________________
Christopher R. Carlen
Principal Laser&Electronics Technologist
Sandia National Laboratories CA USA
(e-mail address removed)
NOTE, delete texts: "RemoveThis" and
"BOGUS" from email address to reply.