Re: Initializing the GUI from a different thread

[email protected]
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
> I have to admit I have a hard time following your discussion, so I
> just want to describe my problem in more detail.
> 
> We already have python bindings for sumo called libsumo where the user
> can start the simulation and modify it from her python script the way
> she likes. Now we want to do the same thing with sumo-gui where the
> obvious thing to do (namely call app.run() when the user starts the
> sim) does not work because run() does not return until the app is
> finished and the second most obvious thing trying to move run() (and
> all the other GUI initialization stuff) to another thread seems not to
> work on Windows as well.
> 
> So is this a FOX limitation which might get fixed in a future version?
> Or is this in general not feasible on Windows (or would need a major
> rework of FOX) and we should simply start a separate GUI process and
> stick to doing things with interprocess communication here?

FOX really likes to work in the main thread.

The core python engine would likely be happy in its own thread, as long
as the two don't fight over the same resources your odds are pretty 
good.

I'd like to bring up something else, you could call it option #3: run 
both
Python and FOX from the same thread.

At least for the interactive interpreter, you should realize both FOX 
and
Python have some sort of read-eval-print loop.

So, you'd have to insert some sort of dispatcher in this loop.

Whenever the python read-eval-print loop starts to wait for input, kick
it into the FOX event loop.

Whenever your FOX event loop builds some input for the python 
interpreter
[for example, you hit return in a text entry box], fall out of the FOX
event loop and let python process the input.

When python is done, and returns to its read-eval-print loop, then 
re-enter
the FOX event loop.

I have done something LIKE this; not with python but another script 
system
which had its own read-eval-print loop.

Key to keep in mind that the FOX event loop is re-entrant.


Hope this helps,

     -- JVZ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.