# -*- coding:gbk-*-
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,title="你好呀PYthon",size=(700,550))
self.panel = wx.Panel(self)
self.panel.SetBackgroundColour("White")
self.button = wx.Button(self.panel,-1,label="快来看我",
pos=(350,290),size=(100,80))
self.Bind(wx.EVT_BUTTON,self.onClick,self.button)
self.button.Bind(wx.EVT_ENTER_WINDOW,self.enterWindow)
self.button.Bind(wx.EVT_LEAVE_WINDOW,self.leaveWindow)
def onClick(self,event):
self.panel.SetBackgroundColour("Blue")
self.panel.Refresh()
def enterWindow(self,event):
self.button.SetLabel("你终于来了")
if self.panel.GetBackgroundColour() != "White":
self.panel.SetBackgroundColour("White")
self.panel.Refresh()
#event.Skip()
def leaveWindow(self,event):
self.button.SetLabel("你又走了呀")
#event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame()
frame.Show()
app.MainLoop()
|