【发布时间】:2020-03-11 00:08:58
【问题描述】:
我似乎找不到使用用户输入动态更新我的 wx 计时器开始间隔的方法。
我正在尝试创建一个可以更新计数时间间隔的计数器程序
下面是我的 Frame 类中的开始时间定义
class MyFrame(wx.Frame):
def __init__(self,parent,title):
global interval
super(MyFrame,self).__init__(parent,title=title,style=wx.MINIMIZE_BOX \
| wx.SYSTEM_MENU\
| wx.CAPTION | wx.CLOSE_BOX\
| wx.CLIP_CHILDREN, size=(1000,1000))
self.interval=3000
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer,self.timer)
self.timer.Start(self.interval)
self.button11 = wx.Button(self, id=wx.ID_ANY, label="Cycle Time",size=(95,60))
self.button11.Bind(wx.EVT_BUTTON, self.Cycletime)
def Cycletime(self,e):
global interval
self.Pause(e)
self.t1 = wx.TextEntryDialog(self, 'Enter Cycle time','Cycle Time',"",style=wx.OK | wx.CANCEL)
self.t1.ShowModal()
if self.t1.ShowModal()==wx.ID_OK:
x_i=self.t1.GetValue()
x_f=float(x_i)
print(x_i)
self.interval=x_f
我的类变量永远不会更新,有什么建议吗?
【问题讨论】:
标签: python-3.x user-interface wxpython wxwidgets