wxPython的Refresh与事件双重响应
2024-10-20 18:49:10
#!/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()
最新文章
- Serial Port Programming on Linux(转载)
- A*算法入门
- 初学MFC
- SecureCRT访问开发板linux系统
- css笔记04:属性选择器
- python-MySQLdb-练习
- [LeetCode] 032. Longest Valid Parentheses (Hard) (C++)
- SVG视野
- js 根据身份证号获取性别,年龄,等
- float浮动属性的基本常识
- O2O淘宝优惠券代码总结
- Spring Boot 静态资源路径分析
- shell脚本--初识CGI
- 一、npm基础
- Linux的notifier机制在TP中的应用【转】
- [py]js前端求和与flask后端求和
- 知识点:Java 内存模型完全解密
- 面向对象的css less 和sass
- win10系统下我的电脑右键没有属性
- C# 获得文件名
热门文章
- 10.1综合强化刷题 Day3 morning
- Decrease (Judge ver.)
- superagent-promise
- 2016北京集训测试赛(九)Problem C: 狂飙突进的幻想乡
- Android性能优化第(一)篇---基本概念
- dedecms图片列表效果调用
- const的限定
- window脚本命令学习(转)
- http://blog.csdn.net/LANGXINLEN/article/details/50421988
- ntp时间服务同步