]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-03/mouse_event.py
5 class MouseEventFrame(wx
.Frame
):
7 def __init__(self
, parent
, id):
8 wx
.Frame
.__init
__(self
, parent
, id, 'Frame With Button',
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
)
16 def OnButtonClick(self
, event
):
17 self
.panel
.SetBackgroundColour('Green')
20 def OnEnterWindow(self
, event
):
21 self
.button
.SetLabel("Over Me!")
24 def OnLeaveWindow(self
, event
):
25 self
.button
.SetLabel("Not Over")
29 if __name__
== '__main__':
30 app
= wx
.PySimpleApp()
31 frame
= MouseEventFrame(parent
=None, id=-1)