Or, attach a generator to the panel that gets loaded on creation (or
during another event) and use the generator.next()
method during the button's event call.
Test for a stop iteration exception and disable the button when this
point is reached. Enable it once the generator is loaded again.
Josh
On Thu, Mar 24, 2011 at 10:09 AM, Tim Roberts <t...@probo.com> wrote:
> tsenate wrote:
>> I'm quite new to wxPython, and still trying to work things out.
>> I have an issue, where I have a loop that I want to iterate through,
>> but only +1 when a button is pushed. This is because on each
>> iteration, I want to go to a user input. Is this possible?
>> e.g.
>> def user_input:
>> #ask user to do something
>> #on button return to submit for next iteration
>> def submit:
>> for f in files:
>> # 1. do some stuff
>> # 2. go to user_input
>> I hope this makes sense, and thanks for any help.
> You have to think about things from an event-driven point of view, which
> is upside-down from traditional linear programming. Basically, you
> aren't in charge. Instead, your program is just a set of functions that
> the operating system calls when something interesting happens.
> What that means is that you have to do your state differently. Instead
> of having a nice simple loop where you wait for things, you need to
> store counters in "persistent" variables, so that each time you get a
> button press, you can go do the next step.
> For example, based on reading between the lines in your design:
> def __init__(self):
> ...
> self.pending_file_list =
> def processOneFile(self):
> if self.pending_file_list:
> next_file = self.pending_file_list.pop(0)
> ... do some stuff ...
> ... tell user to input something ...
> def onSubmit(self,evt):
> self.pending_file_list = ...list of files to process...
> self.processOneFile()
> def onUserApproval(self,evt):
> self.processOneFile()
> Do you see the philosophy? The "pending_file_list" contains the list of
> work yet to be done. Each time I get a user input, I go process one
> file and then exit, going back to the system to wait for the next user
> event. There are many ways to tell the user "I'm waiting for you". For
> example, you could have a "Continue" button that gets disabled until
> processOneFile is ready for the next step.
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
> or visithttp://groups.google.com/group/wxPython-users?hl=en
--
Josh English
Joshua.R.Engl...@gmail.comhttp://joshenglish.livejournal.com