root/trunk/twisted/internet/wxsupport.py

Revision 24441, 1.4 KB (checked in by thijs, 2 years 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
7twisted.internet.wxreactor is probably a better choice.
8
9To use::
10
11    | # given a wxApp instance called myWxAppInstance:
12    | from twisted.internet import wxsupport
13    | wxsupport.install(myWxAppInstance)
14   
15Use Twisted's APIs for running and stopping the event loop, don't use
16wxPython's methods.
17
18On Windows the Twisted event loop might block when dialogs are open
19or menus are selected.
20
21Maintainer: Itamar Shtull-Trauring
22"""
23
24import warnings
25warnings.warn("wxsupport is not fully functional on Windows, wxreactor is better.")
26
27# wxPython imports
28from wxPython.wx import wxApp
29
30# twisted imports
31from twisted.internet import reactor
32from twisted.python.runtime import platformType
33
34
35class 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
55def 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.