zoukankan      html  css  js  c++  java
  • wxPython的Refresh与事件双重响应

    #!/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()
  • 相关阅读:
    ajax
    Django之modelform组件
    Django之form组件
    orm事务与锁
    orm之多表操作
    orm之单表操作
    Django之orm
    Django之模板系统
    Django之视图
    hdu5698瞬间移动(杨辉三角+快速幂+逆元)
  • 原文地址:https://www.cnblogs.com/findumars/p/3618605.html
Copyright © 2011-2022 走看看