我想用上传量表制作一个上传程序。我有函数,它是回调函数:
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%):
答案 0 :(得分:1)
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()
答案 1 :(得分:0)
在文件上传时,您似乎需要一个工作线程来更新GUI。尝试使用线程模块:
import threading
def myupdater(self):
while self.still_uploading:
#do stuff
threading.Thread(target=myupdater).start()
#upload stuff here