I am new to Python and I'm trying to make a simple updating window. Most suggest I should use wxtimer for the task. I have tried to get it going but it fails. Here is the code without a timer that works for me. I had been using time.sleep in my working terminal version. I've looked over several examples, but nothing seems to work on my system. You can see what I am trying to do by looking at the stuff that is commented out. Can anybody help?
import wx
from get_last_google import last_price
class EnterData(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, 'Data Entry', size=(400, 100))
panel = wx.Panel(self, -1)
#self.timer = wx.timer(self)
#self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
#self.timer.start(1000)
text = wx.TextEntryDialog(None, "Enter ticker:", 'Real-Time Ticker', '<Enter Symbol>')
if text.ShowModal()==wx.ID_OK:
symbol=text.GetValue()
self.Show(True)
#def on_timer(self, event):
a=last_price("",symbol)
wx.StaticText(panel, -1, a.symbol+" "+str(a.Last)+" "+a.MDY, (10,10)) # this was different...
#Could be anything really
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = EnterData().Show()
app.MainLoop()
Here is the error I get...
Traceback (most recent call last):
File "/Stocks/menu1.py", line 74, in <module>
frame = EnterData().Show()
File "/Stocks/menu1.py", line 38, in __init__
self.timer = wx.timer(self)
AttributeError: 'module' object has no attribute 'timer'