root / trunk / twisted / internet / wxsupport.py

Revision 24441, 1.4 kB (checked in by thijs, 1 year ago)

Merge maintainer-email-2438: Get rid of references to maintainer email addresses from code.

Author: thijs
Reviewer: exarkun
Fixes: #2438

Line 
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 #
5 """Old method of wxPython support for Twisted.
6
7 twisted.internet.wxreactor is probably a better choice.
8
9 To use::
10
11     | # given a wxApp instance called myWxAppInstance:
12     | from twisted.internet import wxsupport
13     | wxsupport.install(myWxAppInstance)
14     
15 Use Twisted's APIs for running and stopping the event loop, don't use
16 wxPython's methods.
17
18 On Windows the Twisted event loop might block when dialogs are open
19 or menus are selected.
20
21 Maintainer: Itamar Shtull-Trauring
22 """
23
24 import warnings
25 warnings.warn("wxsupport is not fully functional on Windows, wxreactor is better.")
26
27 # wxPython imports
28 from wxPython.wx import wxApp
29
30 # twisted imports
31 from twisted.internet import reactor
32 from twisted.python.runtime import platformType
33
34
35 class wxRunner:
36     """Make sure GUI events are handled."""
37    
38     def __init__(self, app):
39         self.app = app
40        
41     def run(self):
42         """
43         Execute pending WX events followed by WX idle events and
44         reschedule.
45         """
46         # run wx events
47         while self.app.Pending():
48             self.app.Dispatch()
49        
50         # run wx idle events
51         self.app.ProcessIdle()
52         reactor.callLater(0.02, self.run)
53
54
55 def install(app):
56     """Install the wxPython support, given a wxApp instance"""
57     runner = wxRunner(app)
58     reactor.callLater(0.02, runner.run)
59
60
61 __all__ = ["install"]
Note: See TracBrowser for help on using the browser.