Could I use threads ?

Thanks Frank.
I think your code is excellent in pointing me on the right course.
Have a nice Seder or Easter Eggs Hunt (as the case may be),
Ron.

···

-----Original Message-----
From: Frank Millman [mailto:frank@chagford.com]
Sent: Tuesday, April 07, 2009 15:00
To: wxpython-users@lists.wxwidgets.org
Subject: RE: [wxpython-users] Could I use threads ?

Barak, Ron wrote:
>
> Hi All,
>
> I'd like to ask your views on how to solve the following:
>
> I have a wxPython application that process information
into tables
> (that are displayed as wx.Grids).
> Depending on the amount of data, it takes ~8-35 minutes
to create one
> of these tables.
> I thought of putting the logic for that table's creation in a
> separate thread, so that the user could start its creation, use the
> other tables, and return later to this table.
>
> As I have never used threads, I read on threading in
Python/wxPython,
> and I'm now under the impression that Python allows only one active
> thread.
>
> If my impression is true, could you suggest URLs which
could help me
> solve the multitasking issue I outlined above.
>
> Could I use threads ? Need I use different processes (e.g.,
forking) ?
>

I don't know if threads are the right answer to your problem,
but they are certainly not difficult. Attached is a very
simple example of two threads running concurrently - one
running wxPython, the other simulating a long calculation.

As you probably know, the second thread cannot call any wx
methods directly, so you will see that I use wx.CallAfter in
the second thread to update the gui in the main thread.

Hope this gives you some ideas.

Frank Millman