Forking wxPython process with os.fork

you could use:

" threading.Thread "

unless you really need to create new processes, i would go with threading instead. it will save you quite a bit of headaches.

···

Robin Dunn robin@alldunn.com wrote:

Marcin Komorowski wrote:

Hello,

I am writing a GUI logging module that I want to use in conjunction with
a testing script I am writing in Python. The idea is that I launch the
wxPython dialog with a text control and than keep on appending the log
messages as the test progresses.

My problem is that in order to launch a wxPython dialog I have to
execute app.MainLoop(), which does not return till the dialog quits - I
can’t run my tests.

I attempted to address this by forking the
GUI part into a separate
thread, using the following code:

pid = os.fork()
if pid: # We are the parent
log.log_frame.txtctrl_log.AppendText(“Hello\n”)

else: # We are the child
log.app.MainLoop()

This, however, does not seem to work. I am relatively new at Python
programming and a newbe with wxPython. Please help.

I am running Python 2.3.5 on OSX Tiger (10.4.11)

Thank You,
Marcin

P.S. Another approach I am considering is to fork before defining the
GUI, than define and start the GUI in one thread, and do testing in the
other. However, I do not know how to implement inter-thread
communication under Python.

os.fork creates a new copy of the process, which is probably not what
you want. Take a look at the threading module in the Python docs, and
then read
LongRunningTasks - wxPyWiki


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Sagar Khushalani

Graduate Student, UTA

Networking / Systems and Architecture
s.khushalani@yahoo.co.uk
http://www.sagark.info


Sent from Yahoo! Mail.

A Smarter Inbox.