Pastebin 链接:http://pastebin.com/f40ae1bcf
问题:我做了一个wx.Gauge,范围是50。然后是一个在程序空闲时更新Gauge值的函数。当仪表充满大约 50% 时,它会变空并且暂时不显示任何内容。当它这样做时,值实际上是50,我认为当值是50时,它应该是满的。
为什么要这样做?我还尝试使用 wx.Timer 而不是绑定(bind)到 wx.EVT_IDLE,但我没有运气。
最佳答案
一些事情。
- 我无法在我的 iMac 上重现这一点,它已经完全耗尽了。 Python 2.5.4、wxPython 2.8.9.2
- 空闲事件可能会在奇怪的时间发生。尝试将
print event
添加到您的空闲处理程序中,以准确查看这些事件何时到来。最好有一个计时器。仪表移动得非常快还是闪烁? - 您也可以尝试调用 gauge.Update() 来强制完全重绘。
- 我总是使用 100 作为我的仪表限制,也许只是尝试一下。
比计时器更简单的方法可能是:
import wx
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.update_gauge()
def update_gauge(self):
self.count = self.count + 1
if self.count >= 50:
self.count = 0
self.gauge.SetValue(self.count)
wx.CallLater(100, self.update_gauge)
app = wx.PySimpleApp()
GaugeFrame().Show()
app.MainLoop()
关于python - wxPython量规问题(跳过),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1235884/