Hi Mailing,
I have implemented the following wxTimer in wxPython:
self.timer = wx.Timer(self.gui, id=1)
self.miliseconds = 100
self.timer.Start(self.miliseconds)
self.gui.Bind(wx.EVT_TIMER, self.onTimer, id=1)
def onTimer(self, event):
self.time
= self.time + self.miliseconds
I am now timing with my watch if it updates accurately.
I found out that when I use milliseconds closer to 1000, it is very accurate,
but when I use lower values, the timing is not correct anymore.
I was first using more than one timer, but I have
stripped the code to only one timer in the current version. Here are some
outputs.
Watch: wxTimer: self.miliseconds:
4 s 3.7 s
100
4 s 3.3 s
50
4 s 3.2 s 25
4 s 2.6 s
10
4 s 1.4 s
5
As you can see, it is not correct and clearly not a
programming error that I am familiar with.
I am using windows and a dual core computer, does
anybody know why this is happening?
I am using the MCV model, this code is from the
controller class. Self.gui is the view class.
Any help is appreciated…
From the docs: "The wxTimer class allows you to execute code at
specified intervals. It's precision is platform-dependent, but in
general will not be better than 1ms nor worse than 1s."
- Josiah
···
On Tue, Jul 1, 2008 at 6:18 AM, Sanne Korzec <sanne@kortec.nl> wrote:
Hi Mailing,
I have implemented the following wxTimer in wxPython:
self.timer = wx.Timer(self.gui, id=1)
self.miliseconds = 100
self.timer.Start(self.miliseconds)
self.gui.Bind(wx.EVT_TIMER, self.onTimer, id=1)
def onTimer(self, event):
self.time = self.time + self.miliseconds
I am now timing with my watch if it updates accurately. I found out that
when I use milliseconds closer to 1000, it is very accurate, but when I use
lower values, the timing is not correct anymore.
I was first using more than one timer, but I have stripped the code to only
one timer in the current version. Here are some outputs.
Watch: wxTimer: self.miliseconds:
4 s 3.7 s 100
4 s 3.3 s 50
4 s 3.2 s 25
4 s 2.6 s 10
4 s 1.4 s 5
As you can see, it is not correct and clearly not a programming error that I
am familiar with.
I am using windows and a dual core computer, does anybody know why this is
happening?
I am using the MCV model, this code is from the controller class. Self.gui
is the view class.
Any help is appreciated…
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Hi Josiah,
In my example it is worse than 1 second!!! The documentation also states
there are several ways to use the wxTimer. I guess what I would like to know
is: which is the best method for my situation...
···
-----Original Message-----
From: Josiah Carlson [mailto:josiah.carlson@gmail.com]
Sent: dinsdag 1 juli 2008 16:25
To: sanne@kortec.nl; wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] wx Timer fluke
From the docs: "The wxTimer class allows you to execute code at
specified intervals. It's precision is platform-dependent, but in
general will not be better than 1ms nor worse than 1s."
- Josiah
On Tue, Jul 1, 2008 at 6:18 AM, Sanne Korzec <sanne@kortec.nl> wrote:
Hi Mailing,
I have implemented the following wxTimer in wxPython:
self.timer = wx.Timer(self.gui, id=1)
self.miliseconds = 100
self.timer.Start(self.miliseconds)
self.gui.Bind(wx.EVT_TIMER, self.onTimer, id=1)
def onTimer(self, event):
self.time = self.time + self.miliseconds
I am now timing with my watch if it updates accurately. I found out that
when I use milliseconds closer to 1000, it is very accurate, but when I
use
lower values, the timing is not correct anymore.
I was first using more than one timer, but I have stripped the code to
only
one timer in the current version. Here are some outputs.
Watch: wxTimer: self.miliseconds:
4 s 3.7 s 100
4 s 3.3 s 50
4 s 3.2 s 25
4 s 2.6 s 10
4 s 1.4 s 5
As you can see, it is not correct and clearly not a programming error that
I
am familiar with.
I am using windows and a dual core computer, does anybody know why this is
happening?
I am using the MCV model, this code is from the controller class. Self.gui
is the view class.
Any help is appreciated.
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
"...in general..." does not mean "guaranteed". Also, the precision is
only "general" for a single timer execution. If a timer is supposed
to execute every 5 ms, and the first time it executes in 9 ms, it's
not going to fire 1ms later, it's going to fire at least 5 ms later.
In your last case below for 5ms, you are actually getting something on
average of 13.3 ms/timer call, which is well within the 1 to 1000 ms
resolution that the documentation claims. It's also 75 calls/second,
which is well beyond what you should expect from a GUI timer instance
(on any platform, wx, Windows, OS X, Linux, GTK, Qt, etc.).
- Josiah
···
On Tue, Jul 1, 2008 at 9:24 AM, Sanne Korzec <sanne@kortec.nl> wrote:
Hi Josiah,
In my example it is worse than 1 second!!! The documentation also states
there are several ways to use the wxTimer. I guess what I would like to know
is: which is the best method for my situation...
-----Original Message-----
From: Josiah Carlson [mailto:josiah.carlson@gmail.com]
Sent: dinsdag 1 juli 2008 16:25
To: sanne@kortec.nl; wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] wx Timer fluke
From the docs: "The wxTimer class allows you to execute code at
specified intervals. It's precision is platform-dependent, but in
general will not be better than 1ms nor worse than 1s."
- Josiah
On Tue, Jul 1, 2008 at 6:18 AM, Sanne Korzec <sanne@kortec.nl> wrote:
Hi Mailing,
I have implemented the following wxTimer in wxPython:
self.timer = wx.Timer(self.gui, id=1)
self.miliseconds = 100
self.timer.Start(self.miliseconds)
self.gui.Bind(wx.EVT_TIMER, self.onTimer, id=1)
def onTimer(self, event):
self.time = self.time + self.miliseconds
I am now timing with my watch if it updates accurately. I found out that
when I use milliseconds closer to 1000, it is very accurate, but when I
use
lower values, the timing is not correct anymore.
I was first using more than one timer, but I have stripped the code to
only
one timer in the current version. Here are some outputs.
Watch: wxTimer: self.miliseconds:
4 s 3.7 s 100
4 s 3.3 s 50
4 s 3.2 s 25
4 s 2.6 s 10
4 s 1.4 s 5
As you can see, it is not correct and clearly not a programming error that
I
am familiar with.
I am using windows and a dual core computer, does anybody know why this is
happening?
I am using the MCV model, this code is from the controller class. Self.gui
is the view class.
Any help is appreciated.
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Sanne Korzec wrote:
In my example it is worse than 1 second!!!
No, it's not. You are GREATLY misinterpreting your results. When you ask for 5ms, you will never get an interval of less than 16ms. However, in your callback, you are only adding 5ms to your accumulator in each event. By the time 4 real seconds have elapsed, you've had about 250 timer events (4000/16), so your accumulator will only show 1.25 (250 x 5).
The documentation also states
there are several ways to use the wxTimer. I guess what I would like to know
is: which is the best method for my situation...
How can we possibly answer that, when you haven't told us anything about "your situation"?
Windows is not a real-time operating system. It does not provide elapsed timer events at a resolution less than about 16ms.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.