tehryan
tehryan

Reputation: 775

cherrypy and wxpython

I'm trying to make a cherrypy application with a wxpython ui. The problem is both libraries use closed loop event handlers. Is there a way for this to work? If I have the wx ui start cherrypy is that going to lock up the ui?

Upvotes: 6

Views: 1596

Answers (4)

fumanchu
fumanchu

Reputation: 14559

See my answer at CherryPy interferes with Twisted shutting down on Windows

In short, CherryPy handles the main loop by default, but it definitely doesn't need to. Stop using quickstart and call engine.start without engine.block, and CP will run in its own threads and leave the main thread for your other framework to control.

Upvotes: 5

DrBloodmoney
DrBloodmoney

Reputation: 2796

I would encourage you to take a look at the Calibre (e-book manager) source. It is written in PyQT, but uses CherryPy to allow people to view their library from outside their LAN.

Upvotes: 1

Noufal Ibrahim
Noufal Ibrahim

Reputation: 72755

One way to decouple them would be to start them up as two separate processes and have them communicate via some kind of IPC mechanism. You might have to write a small adaptor to have them speak a common protocol.

Since you're doing CherryPy, you might also be able to expose a control interface via HTTP which the wx GUI can use to drive your server.

Upvotes: 1

LeafStorm
LeafStorm

Reputation: 3127

If you use threading, you should be able to start up the CherryPy server in one thread and run wxPython in the other. This article (http://wiki.wxpython.org/LongRunningTasks) on the wxPython wiki has some info on threading, and the CherryPy server source code (http://www.cherrypy.org/browser/trunk/cherrypy/wsgiserver/__init__.py) has some documentation on how the server works, and possibly how you could get it to interact with threads.

Upvotes: 1

Related Questions