By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,482 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,482 IT Pros & Developers. It's quick & easy.

wx.Timer not working

P: n/a
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


Jul 26 '08 #1
Share this Question
Share on Google+
3 Replies

P: n/a
On Jul 26, 2:33*pm, 5lvqbw...@sneakemail.com wrote:
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, "Thisis a test")
* * * * * * * * frame1.Show(True)
* * * * * * * * return True

app * * = MyApp(0)
app.MainLoop()

Thanks for any advice!!

Michael
I'm not seeing anything either. Please post this to the wxPython
user's group for additional help:

http://www.wxpython.org/maillist.php

Mike
Jul 26 '08 #2

P: n/a
On Jul 26, 3:13*pm, Mike Driscoll <kyoso...@gmail.comwrote:
On Jul 26, 2:33*pm, 5lvqbw...@sneakemail.com wrote:
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

I'm not seeing anything either. Please post this to the wxPython
user's group for additional help:

http://www.wxpython.org/maillist.php

Mike

I think I figured it out. By looking at the wxTimer example here:
http://wiki.wxpython.org/AnotherTuto...ddb822ea296c92

My code created a temporary timer object and did not make it a class
member. When I changed it to be a class member with self.timer, then
it worked.

thanks
Michael
Jul 26 '08 #3

P: n/a
On Jul 26, 5:22*pm, 5lvqbw...@sneakemail.com wrote:
On Jul 26, 3:13*pm, Mike Driscoll <kyoso...@gmail.comwrote:
On Jul 26, 2:33*pm, 5lvqbw...@sneakemail.com wrote:
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
I'm not seeing anything either. Please post this to the wxPython
user's group for additional help:
http://www.wxpython.org/maillist.php
Mike

I think I figured it out. *By looking at the wxTimer example here:http://wiki.wxpython.org/AnotherTuto...159d81cb03a6dd...

My code created a temporary timer object and did not make it a class
member. *When I changed it to be a class member with self.timer, then
it worked.

thanks
Michael
Ah...I didn't even think about that. I noticed I had self.timer in my
code, but I didn't realize it was required. Sorry I wasn't of more
help. Still, you can learn a lot from the wxPython user's group just
by reading other people's posts.

Mike
Jul 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.