首页 > 代码库 > wxPython入门练习代码 三

wxPython入门练习代码 三

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)14     15     def OnEnterWindow(self,event):16         self.button.SetLabel("Over Me!")17         event.Skip()18     19     def OnLeaveWindow(self,event):20         self.button.SetLabel("Not Over!")21         event.Skip()22         23     def OnButtonClick(self,event):24         self.panel.SetBackgroundColour(Green)25         self.panel.Refresh()26         27     def onm ouseDown(self,event):28         self.button.SetLabel("Again!")29         event.Skip()30         31 if __name__ == __main__:32     app = wx.PySimpleApp()33     frame = DoubleEventFrame(parent=None,id=-1)34     frame.Show()35     app.MainLoop()

 

wxPython入门练习代码 三