##// END OF EJS Templates
Update notes about GUI event loop support.
Fernando Perez -
Show More
@@ -8,7 +8,6 b' In [5]: %gui gtk'
8 8 In [6]: %run gui-gtk.py
9 9 """
10 10
11
12 11 import pygtk
13 12 pygtk.require('2.0')
14 13 import gtk
@@ -38,5 +37,3 b' try:'
38 37 enable_gtk()
39 38 except ImportError:
40 39 gtk.main()
41
42 #gtk.main()
@@ -1,5 +1,10 b''
1 1 #!/usr/bin/env python
2 """A Simple wx example to test IPython's event loop integration.
2 """
3 WARNING: This example is currently broken, see
4 https://github.com/ipython/ipython/issues/645 for details on our progress on
5 this issue.
6
7 A Simple wx example to test IPython's event loop integration.
3 8
4 9 To run this do:
5 10
@@ -98,7 +103,12 b' class MyApp(wx.App):'
98 103 frame.Show(True)
99 104 return True
100 105
106
101 107 if __name__ == '__main__':
108 raise NotImplementedError(
109 'Standalone WX GUI support is currently broken. '
110 'See https://github.com/ipython/ipython/issues/645 for details')
111
102 112 app = wx.GetApp()
103 113 if app is None:
104 114 app = MyApp(redirect=False, clearSigInt=False)
@@ -1117,6 +1117,18 b' GUI event loop support'
1117 1117 .. versionadded:: 0.11
1118 1118 The ``%gui`` magic and :mod:`IPython.lib.inputhook`.
1119 1119
1120 .. warning::
1121
1122 All GUI support with the ``%gui`` magic, described in this section, applies
1123 only to the plain terminal IPython, *not* to the Qt console. The Qt console
1124 currently only supports GUI interaction via the ``--pylab`` flag, as
1125 explained :ref:`in the matplotlib section <matplotlib_support>`.
1126
1127 We intend to correct this limitation as soon as possible, you can track our
1128 progress at issue #643_.
1129
1130 .. _643: https://github.com/ipython/ipython/issues/643
1131
1120 1132 IPython has excellent support for working interactively with Graphical User
1121 1133 Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is
1122 1134 implemented using Python's builtin ``PyOSInputHook`` hook. This implementation
@@ -1145,32 +1157,33 b' object, do::'
1145 1157 For information on IPython's Matplotlib integration (and the ``pylab`` mode)
1146 1158 see :ref:`this section <matplotlib_support>`.
1147 1159
1148 For developers that want to use IPython's GUI event loop integration in
1149 the form of a library, these capabilities are exposed in library form
1150 in the :mod:`IPython.lib.inputhook`. Interested developers should see the
1151 module docstrings for more information, but there are a few points that
1152 should be mentioned here.
1160 For developers that want to use IPython's GUI event loop integration in the
1161 form of a library, these capabilities are exposed in library form in the
1162 :mod:`IPython.lib.inputhook` and :mod:`IPython.lib.guisupport` modules.
1163 Interested developers should see the module docstrings for more information,
1164 but there are a few points that should be mentioned here.
1153 1165
1154 1166 First, the ``PyOSInputHook`` approach only works in command line settings
1155 where readline is activated.
1167 where readline is activated. As indicated in the warning above, we plan on
1168 improving the integration of GUI event loops with the standalone kernel used by
1169 the Qt console and other frontends (issue 643_).
1156 1170
1157 1171 Second, when using the ``PyOSInputHook`` approach, a GUI application should
1158 1172 *not* start its event loop. Instead all of this is handled by the
1159 1173 ``PyOSInputHook``. This means that applications that are meant to be used both
1160 1174 in IPython and as standalone apps need to have special code to detects how the
1161 application is being run. We highly recommend using IPython's
1162 :func:`enable_foo` functions for this. Here is a simple example that shows the
1163 recommended code that should be at the bottom of a wxPython using GUI
1164 application::
1165
1166 try:
1167 from IPython.lib.inputhook import enable_wx
1168 enable_wx(app)
1169 except ImportError:
1170 app.MainLoop()
1171
1172 This pattern should be used instead of the simple ``app.MainLoop()`` code
1173 that a standalone wxPython application would have.
1175 application is being run. We highly recommend using IPython's support for this.
1176 Since the details vary slightly between toolkits, we point you to the various
1177 examples in our source directory :file:`docs/examples/lib` that demonstrate
1178 these capabilities.
1179
1180 .. warning::
1181
1182 The WX version of this is currently broken. While ``--pylab=wx`` works
1183 fine, standalone WX apps do not. See
1184 https://github.com/ipython/ipython/issues/645 for details of our progress on
1185 this issue.
1186
1174 1187
1175 1188 Third, unlike previous versions of IPython, we no longer "hijack" (replace
1176 1189 them with no-ops) the event loops. This is done to allow applications that
General Comments 0
You need to be logged in to leave comments. Login now