| OLD | NEW |
| (Empty) |
| 1 | |
| 2 """ | |
| 3 This module provides support for Twisted to interact with the glib mainloop. | |
| 4 This is like gtk2, but slightly faster and does not require a working | |
| 5 $DISPLAY. However, you cannot run GUIs under this reactor: for that you must | |
| 6 use the gtk2reactor instead. | |
| 7 | |
| 8 In order to use this support, simply do the following:: | |
| 9 | |
| 10 | from twisted.internet import glib2reactor | |
| 11 | glib2reactor.install() | |
| 12 | |
| 13 Then use twisted.internet APIs as usual. The other methods here are not | |
| 14 intended to be called directly. | |
| 15 | |
| 16 When installing the reactor, you can choose whether to use the glib | |
| 17 event loop or the GTK+ event loop which is based on it but adds GUI | |
| 18 integration. | |
| 19 | |
| 20 Maintainer: U{Itamar Shtull-Trauring<mailto:twisted@itamarst.org>} | |
| 21 """ | |
| 22 | |
| 23 from twisted.internet import gtk2reactor | |
| 24 | |
| 25 | |
| 26 | |
| 27 class Glib2Reactor(gtk2reactor.Gtk2Reactor): | |
| 28 """ | |
| 29 The reactor using the glib mainloop. | |
| 30 """ | |
| 31 | |
| 32 def __init__(self): | |
| 33 """ | |
| 34 Override init to set the C{useGtk} flag. | |
| 35 """ | |
| 36 gtk2reactor.Gtk2Reactor.__init__(self, useGtk=False) | |
| 37 | |
| 38 | |
| 39 | |
| 40 def install(): | |
| 41 """ | |
| 42 Configure the twisted mainloop to be run inside the glib mainloop. | |
| 43 """ | |
| 44 reactor = Glib2Reactor() | |
| 45 from twisted.internet.main import installReactor | |
| 46 installReactor(reactor) | |
| 47 | |
| 48 __all__ = ['install'] | |
| 49 | |
| OLD | NEW |