473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

wx.Timer not working

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
3 2653
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
7
by: J. Hill | last post by:
I have a Windows Service with a timer but the .Tick event is not being fired/called. Don't know what code to include...I enabled and started the timer...I have the exact same code in a Windows...
2
by: hnkien | last post by:
Hi, I am writing a windows service with threading.timer for 10 seconds but it didn't work. Here are my code: namespace SchedulerService { public class ScheduleService :...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
3
by: sherifffruitfly | last post by:
I admit it - I don't have the foggiest notion how to use the timer class(es) in c# - i've looked at tutorials, and it's still completely unintutive to me. Anyone nice enough to get me started on...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
4
by: Max | last post by:
This may be an elementary question but it's something I have not encountered in about 10 years writing code in VB 5 / 6 I have a timer that using the API checks if there has been a change to one...
4
by: sophistiKate | last post by:
I am working with an Access 2003 database. Since adding a timer event to check for idle time to a form, a custom toolbar button that creates a snapshot has stopped working properly. Until the first...
11
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.