DoubleEventFrame.py:
1
#
!/usr/bin/env/ python
2
3
import
wx
4
5
class
DoubleEventFrame(wx.Frame):
6
def
__init__
(self,parent,id):
7 wx.Frame.__init__(self,parent,id,‘Frame with buttom‘,size=(300,100))
8 self.panel = wx.Panel(self,-1)
9 self.button = wx.Button(self.panel,-1,"Click Me",pos=(100,15))
10 self.Bind(wx.EVT_BUTTON,self.OnButtonClick,self.button)
11 self.button.Bind(wx.EVT_LEFT_DOWN,self.OnMouseDown)
12 self.button.Bind(wx.EVT_ENTER_WINDOW,self.OnEnterWindow)
13 self.button.Bind(wx.EVT_LEAVE_WINDOW,self.OnLeaveWindow)
1415def OnEnterWindow(self,event):
16 self.button.SetLabel("Over Me!")
17 event.Skip()
1819def OnLeaveWindow(self,event):
20 self.button.SetLabel("Not Over!")
21 event.Skip()
2223def OnButtonClick(self,event):
24 self.panel.SetBackgroundColour(‘Green‘)
25 self.panel.Refresh()
2627def OnMouseDown(self,event):
28 self.button.SetLabel("Again!")
29 event.Skip()
3031if__name__ == ‘__main__‘:
32 app = wx.PySimpleApp()
33 frame = DoubleEventFrame(parent=None,id=-1)
34 frame.Show()
35 app.MainLoop()
原文:http://www.cnblogs.com/ljfy-yjw/p/5828047.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!