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

wxpython: how does EVT_IDLE work?

P: n/a
Quick question about the code below: I understand why the progress bar
fills up at a steady pace when the mouse is idle over the frame; but
why, when you move the mouse, does the progress bar speed up? Shouldn't
it stop completely until the mouse is idle again?

Also, on a side note, I'm confused by the use of the word "bevel" and
"bezel". The methods seem to use "bezel", but according to wxPython in
Action, it's referring to the bevel of the border of the widget. Also,
the book refers to a method called SetBevelWidth(), but the code shows
it as SetBezelWidth() -- and only the latter works -- so what's the deal
with these words?

Thanks!

--------------------------------------

import wx

class GaugeFrame(wx.Frame):

def __init__(self):
wx.Frame.__init__(self, None, -1, 'Gauge Example')
panel = wx.Panel(self)
self.count = 0
self.gauge = wx.Gauge(panel, -1, 50, (20, 50), (250, 25))
self.gauge.SetBevelFace(3)
self.gauge.SetShadowWidth(3)
self.Bind(wx.EVT_IDLE, self.OnIdle)

def OnIdle(self, event):
self.count += 1
if self.count >= 50:
self.count = 0
self.gauge.SetValue(self.count)

if __name__ == '__main__':
app = wx.App(redirect=False)
GaugeFrame().Show()
app.MainLoop()
Jul 10 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
John Salerno wrote:
Quick question about the code below: I understand why the progress bar
fills up at a steady pace when the mouse is idle over the frame; but
why, when you move the mouse, does the progress bar speed up? Shouldn't
it stop completely until the mouse is idle again?
Ok, now I'm really confused. I just ran the code again and this time it
*doesn't* increase the progress bar when the mouse is idle, and it only
increases when I move it. This wasn't the behavior just a few minutes
ago, and I didn't change anything! What's going on?
self.gauge.SetBevelFace(3)
Should be 'Bezel'.
Jul 10 '06 #2

P: n/a
John Salerno wrote:
Ok, now I'm really confused. I just ran the code again and this time it
*doesn't* increase the progress bar when the mouse is idle, and it only
increases when I move it. This wasn't the behavior just a few minutes
ago, and I didn't change anything! What's going on?
Ok, this helps explain why moving the mouse causes the idle event:

"Note that, unless you do something specifically, the idle events are
not sent if the system remains idle once it has become it, e.g. only a
single idle event will be generated until something else resulting in
more normal events happens and only then is the next idle event sent again."

But I'm still confused about why *not* moving the mouse still allowed
the progress bar to increase (although that behavior has stopped now for
some reason).
Jul 10 '06 #3

P: n/a
John Salerno wrote in news:Wj******************@news.tufts.edu in
comp.lang.python:
Quick question about the code below: I understand why the progress bar
fills up at a steady pace when the mouse is idle over the frame; but
why, when you move the mouse, does the progress bar speed up? Shouldn't
it stop completely until the mouse is idle again?
wxWidgets is sending the idle event after it has processed all
other events, but it just sends it once not in a loop.

see the documentation (help) for wxIdleEvent::RequestMore.

>
def OnIdle(self, event):
event.RequestMore(True)
self.count += 1
if self.count >= 50:
self.count = 0
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.