python - Wxpython的仪表不刷新

标签 python wxpython

我想制作一个带有上传量规的上传程序。我有一个回调函数:

def myupdater(self, current, total):

    m = (Decimal(current)/Decimal(total))
    print "uploaded {0}/{1} so far".format(current, total)
    self.gauge_1.SetValue(m)
    print(m)
    print (self.gauge_1.GetValue)
    wx.Yield()
    print"----------------------"

它显示(仪表最后仅更改为 100%):

http://pastebin.com/eM40e6mv

完整代码: http://pastebin.com/uaThd5sD

最佳答案

Gauge's range is int type.传递小于 1 的值将被视为 0。按如下所示更改 gauge_1 .. 行:

self.gauge_1 = wx.Gauge(self.notebook_1_pane_1, -1, 100)

更改myupdater如下:

def myupdater(self, current, total):
    m = 100 * current / total
    self.gauge_1.SetValue(m)
    wx.Yield()

关于python - Wxpython的仪表不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17253283/

相关文章:

python - 查找 numpy 数组中超过先前值的值的索引

python - TensorFlow 对象检测 API 错误

python - 使用wxPython.FileDialog保存文件

python - wxpython - 一个框架,多个面板,模块化代码

python - 大数与长整数之间的除法 : how to bypass float conversion?

python - 如何避免在修改时将 "keras_learning_phase"添加到模型中?

python - PyDeadObjectError 和状态栏

python - 使用 matplotlib 将 networkx 图嵌入到 wxPython 中

python - 光谱聚类 Scikit 学习集群中的打印项目

python - 最终用户的计算机上是否需要 wxPython