#!/usr/bin/env python import wx class DoubleEventFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame With Button', size=(300, 100)) self.panel = wx.Panel(self, -1) self.cc = 1 self.button = wx.Button(self.panel, -1, "Click Me", pos=(100, 15)) self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.button) self.button.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) def OnButtonClick(self, event): if self.cc == 1: self.panel.SetBackgroundColour('Green') self.cc = 2 else: self.panel.SetBackgroundColour('RED') self.cc = 1 self.panel.Refresh() # 这里不管self.Refresh(),只要是parent,或者parent的parent进行Refresh()都可以 def OnMouseDown(self, event): self.button.SetLabel("Again!") event.Skip() # 这里,处理完消息以后,还可以继续传递同一条消息继续处理。 if __name__ == '__main__': app = wx.PySimpleApp() frame = DoubleEventFrame(parent=None, id=-1) frame.Show() app.MainLoop()