wxpython: how does EVT_IDLE work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Salerno

    #1

    wxpython: how does EVT_IDLE work?

    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.F rame):

    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.SetB evelFace(3)
    self.gauge.SetS hadowWidth(3)
    self.Bind(wx.EV T_IDLE, self.OnIdle)

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

    if __name__ == '__main__':
    app = wx.App(redirect =False)
    GaugeFrame().Sh ow()
    app.MainLoop()
  • John Salerno

    #2
    Re: wxpython: how does EVT_IDLE work?

    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.SetB evelFace(3)
    Should be 'Bezel'.

    Comment

    • John Salerno

      #3
      Re: wxpython: how does EVT_IDLE work?

      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).

      Comment

      • Rob Williscroft

        #4
        Re: wxpython: how does EVT_IDLE work?

        John Salerno wrote in news:Wjysg.2445 $No6.49710@news .tufts.edu in
        comp.lang.pytho n:
        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::Re questMore.

        >
        def OnIdle(self, event):
        event.RequestMo re(True)
        self.count += 1
        if self.count >= 50:
        self.count = 0
        Rob.
        --

        Comment

        Working...