weixin_43660316 2019-09-27 22:39 采纳率: 75%
浏览 510

wxpython进度条由线程进行控制,为何没有滚动?

用threading控制wxpython的gauge的进度。
我在网上抄了一段代码,稍微改写了一下,运行的是,进度条不能滚动,这是为什么?请各位老师指点。

import wx
import threading
import time


class GaugeFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Gauge Example', size=(350, 150))
        panel = wx.Panel(self, -1)
        self.count = 0
        self.gauge = wx.Gauge(panel, -1, 50, (20, 50), (250, 25))
        self.gauge.SetBezelFace(3)
        self.gauge.SetShadowWidth(3)
        self.Bind(wx.EVT_IDLE, self.OnIdle)

    def OnIdle(self, event):
        self.gauge.SetValue(self.count)
        if self.count ==100:
            self.gauge.Destroy()

    def timer(self):
        while self.count < 100:
            self.count = self.count + 1
            time.sleep(2)


if __name__ == '__main__':
    app = wx.App()
    frame = GaugeFrame()
    frame.Show()
    threading.Thread(target=frame.timer())
    app.MainLoop()


  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog