wx.Timer not working
Vlastimil Brom
vlastimil.brom at gmail.com
Sat Jul 26 16:13:46 EDT 2008
2008/7/26 <5lvqbwl02 at sneakemail.com>
> Windows XP SP3
> Python 2.5
> wx.version() = '2.8.1.1 (msw-unicode)'
> ------
> I have written the following *simplest* implementation of wx.timer I
> can think of. No workie. I want an exception, a print statement, or
> something.
>
> The wxpython demos all work, but for some reason this isn't. The
> demos are simple and straghtforward, so I think I understand how it
> should work. Clues please? I've tried variations of ID's, SetOwners,
> using and redefining Notify(), Bind, Connect, etc. In the cases where
> the interpreter doesn't complain about passed argument types, the
> callback function is never called.
>
>
> import wx
>
> class MyFrame(wx.Frame):
> def __init__(self, parent, id, title):
> wx.Frame.__init__(self, parent, id, title, pos=(100,
> 100))
>
> timer = wx.Timer(self, -1)
> self.Bind(wx.EVT_TIMER, self.OnTick, timer)
> timer.Start(100)
>
> def OnTick(self, event):
> print 'Hi. Bye.'
> 1/0 #<-- should crash as evidence callback is being called
>
> class MyApp(wx.App):
> def OnInit(self):
> frame1 = MyFrame(None, wx.ID_ANY, "This is a test")
> frame1.Show(True)
> return True
>
> app = MyApp(0)
> app.MainLoop()
>
>
> Thanks for any advice!!
>
> Michael
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Hi,
not exactly sure, but compared to the demo, it seems to be a binding
problem;
Using "self.timer" instead of "timer" in the __init__ section
and
self.Bind(wx.EVT_TIMER, self.OnTick)
instead of
self.Bind(wx.EVT_TIMER, self.OnTick, timer)
seems to work;
HTH,
Vlasta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080726/c2fbcd49/attachment-0001.html>
More information about the Python-list
mailing list