]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-03/mouse_event.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-03 / mouse_event.py
1 #!/usr/bin/env python
2
3 import wx
4
5 class MouseEventFrame(wx.Frame):
6
7 def __init__(self, parent, id):
8 wx.Frame.__init__(self, parent, id, 'Frame With Button',
9 size=(300, 100))
10 self.panel = wx.Panel(self)
11 self.button = wx.Button(self.panel, label="Not Over", pos=(100, 15))
12 self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.button)
13 self.button.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
14 self.button.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
15
16 def OnButtonClick(self, event):
17 self.panel.SetBackgroundColour('Green')
18 self.panel.Refresh()
19
20 def OnEnterWindow(self, event):
21 self.button.SetLabel("Over Me!")
22 event.Skip()
23
24 def OnLeaveWindow(self, event):
25 self.button.SetLabel("Not Over")
26 event.Skip()
27
28
29 if __name__ == '__main__':
30 app = wx.PySimpleApp()
31 frame = MouseEventFrame(parent=None, id=-1)
32 frame.Show()
33 app.MainLoop()
34