Michael S <[EMAIL PROTECTED]> wrote: > If I create a threading.Thread derived class, and run > the wxPython code in the main thread; using a lock, > will I be able to suspend the Thread, even though it > will run the C code, which is essentially a while loop > looping through millions of lines of a text file?
If all your C code is doing is looping through lines in a text file, you can rewrite it fairly reasonably in Python via 'for line in open(fn):'. In terms of locks, you have to use a lock that can be acquired by either thread (GUI or C), but that won't necessarily give you what you want; the GUI thread in wxPython may still not like being called directly. If you want the ability to easily restart your C code, you may want to consider at least looking at the following page on coroutines in C: http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html . It would allow you to do all of your GUI manipulation/updating in Python without having to worry about locks or calling Python code from C. - Josiah > --- Josiah Carlson <[EMAIL PROTECTED]> wrote: > > > > > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > > At Tuesday 24/10/2006 23:25, Michael S wrote: > > > > > > >I extended part of my program in C, since that > > part > > > >was too involved for Python. Now when I import > > the > > > >module I created and call its functions, I am > > trying > > > >to feedback some information bac to my wxPython > > > >program. The function runs for a while and I > > wanted to > > > >update a progress bar, but when I call the > > function of > > > >my new module, wxPython doesn't respond when > > wx.Timer > > > >is supposed to fire. > > > > > > Does your extension run on a separate thread? I > > guess not. So the > > > wxPython code does not have a chance to run. > > > Do it the other way: from your C code, call a > > Python function which > > > in turn updates the progress bar (and keep it > > simple!) > > > > Unless the GUI thread has a chance to take passes > > through the wxPython > > mainloop, the progress bar, etc., may not actually > > be updated on some > > platforms. > > > > Mr. Sherman would likely be better off creating a > > new thread which > > handles processing, which could update a C global > > variable, which the > > GUI thread can poll to update its progress bar, etc. > > Alternatively, if > > the processing can be broken down into smaller > > pieces, the secondary > > thread can call the pieces and post events back to > > the GUI thread to > > update the progress bar (via explicit wx.PostEvent > > or implicit > > wx.CallAfter). > > > > > > - Josiah > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > -- http://mail.python.org/mailman/listinfo/python-list