Newbie question on messaging

I've been using Bind etc in a cookbook way to respond to common messages, but I guess it's time to learn how it really works. Here's what I'm trying to do:

  def init(. . .):
    self.Bind(wx.EVT_MENU, self.KeepGoingTill, id= . . .)

  def KeepGoingTill(self, evt):
    while 1:
      if {user presses, or has pressed, a mouse button}:
        break
      self.doSomethingAgain()

I can imagine ways to kludge this (setting flags etc), but there has to be a right way to do it and I'd like to learn. Somebody start me on the right path?

Charles Hartman
Professor of English, Poet in Residence
Connecticut College
http://cherry.conncoll.edu/cohar
http://villex.blogspot.com

Charles Hartman wrote:

Here's what I'm trying to do:

    def init(. . .):
        self.Bind(wx.EVT_MENU, self.KeepGoingTill, id= . . .)

    def KeepGoingTill(self, evt):
        while 1:
            if {user presses, or has pressed, a mouse button}:
                break
            self.doSomethingAgain()

Can you give us more info about what you want to "Keep Going". What it is will help determine the best solution. A few hints in the meantime:

When a callback is called, KeepGoingTill(), in this case, the event queue is not re-visited until it returns. What that means is that you won't get the key-presses, etc, until after function finishes. You can put a wxApp.Yield() in there, to ask the system to process events, but then it could do anything. I'm at a loss for a general solution without a better idea what you need to do.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov