[Twisted-Python] twisted robot ...
Hi All, Thanks to everyone for the recent help on integration of twisted with wxPython. We are going to hold off on using Bob's new code at the moment in favour of using the release version of Twisted (easier for the users to install). At the moment we've got Twisted in the main thread, spawning a thread to run wx. It works nicely except we can't figure out how to communicate with wx (ie., generate wxevents) from twisted. (We don't need the converse - it's notification only.) I fly out to San Francisco tommorrow morning so any help would be most appreciated. So about the robot subject line ... we bought a 50cm RC tank on Ebay, ripped it down to the chassis and added a platform for carrying around a 12" Powerbook. The laptop runs our twisted server which drives a USB controllable Phidget (www.phidget.com) to control the tank treads and a servo motor for camera (iSight) tilt. We talk to the server via wifi. The client app (wx GUI is done and working) is what we are working on at the moment... Cheers, Darran. P.S. I'll put some photos and video up on my web site for anyone interested. -- Darran Edmundson (darran.edmundson@anu.edu.au) ANU Supercomputer Facility Vizlab Australian National University, Canberra, ACT 2600 tel: +61 2 6125-0517 fax: +61 2 6125-5088
On Apr 21, 2005, at 11:22 PM, Darran Edmundson wrote:
Thanks to everyone for the recent help on integration of twisted with wxPython. We are going to hold off on using Bob's new code at the moment in favour of using the release version of Twisted (easier for the users to install).
You could copy the new reactor code (plus the patched wakers).. it would work with release twisted. -bob
Hi,
At the moment we've got Twisted in the main thread, spawning a thread to run wx. It works nicely except we can't figure out how to communicate with wx (ie., generate wxevents) from twisted. (We don't need the converse - it's notification only.)
You just have to call wx.CallAfter, it will let you call any function inside the wx thread. I've put an example of this use online: http://solipsis.netofpeers.net/wiki/WxTwistedExample It may be better, by the way, to run wx in the main thread and Twisted in the secondary thread. Some toolkits supported by wx may not like the fact that they aren't called from the main thread - I'm not sure such a limitation exists but I'm not sure of the contrary either. Twisted, OTOH, does not seem to care at all. Regards Antoine.
On Mon, 2005-04-25 at 16:15 +0200, Antoine Pitrou wrote:
It may be better, by the way, to run wx in the main thread and Twisted in the secondary thread. Some toolkits supported by wx may not like the fact that they aren't called from the main thread - I'm not sure such a limitation exists but I'm not sure of the contrary either. Twisted, OTOH, does not seem to care at all.
Twisted does care about this for signal handling. If Twisted is run in a thread it will not be able to do shutdown based on signals or run processes correctly (though if you install your own signal handlers that forward info to twisted it can be made to work).
participants (4)
-
Antoine Pitrou
-
Bob Ippolito
-
Darran Edmundson
-
Itamar Shtull-Trauring