wxPython下Gauge进度条由线程控制
2016-06-07 00:00
1356 查看
import wx
import time
import thread
class GuageFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Gauge Example', size = (500, 200))
panel = wx.Panel(self, -1)
panel.SetBackgroundColour("white")
self.count = 0
self.gauge = wx.Gauge(panel, -1, 10, (50, 50), (300, 20), style = wx.GA_PROGRESSBAR)
self.gauge.SetBezelFace(3)
self.gauge.SetShadowWidth(3)
#进度条自身绑定循环任务,监听进度
self.gauge.Bind(wx.EVT_IDLE, self.OnIdle)
self.Center(True)
def OnIdle(self, event):
self.gauge.SetValue(self.count)
if self.count == 10:
#到达计划进度,取消进度条
self.gauge.Destroy()
def timer(self, no, interval):
while self.count<10:
time.sleep(interval)
self.count += 1
if __name__ == '__main__':
app = wx.App()
frame = GuageFrame()
frame.Show()
#创建线程,设定延迟加载时间及间隔执行时间
thread.start_new_thread(frame.timer, (0.5,0.2))
app.MainLoop()
import time
import thread
class GuageFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Gauge Example', size = (500, 200))
panel = wx.Panel(self, -1)
panel.SetBackgroundColour("white")
self.count = 0
self.gauge = wx.Gauge(panel, -1, 10, (50, 50), (300, 20), style = wx.GA_PROGRESSBAR)
self.gauge.SetBezelFace(3)
self.gauge.SetShadowWidth(3)
#进度条自身绑定循环任务,监听进度
self.gauge.Bind(wx.EVT_IDLE, self.OnIdle)
self.Center(True)
def OnIdle(self, event):
self.gauge.SetValue(self.count)
if self.count == 10:
#到达计划进度,取消进度条
self.gauge.Destroy()
def timer(self, no, interval):
while self.count<10:
time.sleep(interval)
self.count += 1
if __name__ == '__main__':
app = wx.App()
frame = GuageFrame()
frame.Show()
#创建线程,设定延迟加载时间及间隔执行时间
thread.start_new_thread(frame.timer, (0.5,0.2))
app.MainLoop()
相关文章推荐
- wxpython 学习笔记 第一天
- 使用wxpython实现的一个简单图片浏览器实例
- python通过wxPython打开一个音频文件并播放的方法
- python之wxPython应用实例
- python使用wxpython开发简单记事本的方法
- wxPython使用系统剪切板的方法
- 将图片文件嵌入到wxpython代码中的实现方法
- wxPython 入门教程
- 有关wxpython pyqt内存占用问题分析
- Python中使用wxPython开发的一个简易笔记本程序实例
- wxPython窗口的继承机制实例分析
- wxPython学习之主框架实例
- wxPython窗口中文乱码解决方法
- wxpython 最小化到托盘与欢迎图片的实现方法
- wxPython中文教程入门实例
- wxPython框架类和面板类的使用实例
- wxPython事件驱动实例详解
- wxpython学习笔记(推荐查看)
- wxPython定时器wx.Timer简单应用实例
- wxpython中利用线程防止假死的实现方法