##// 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 In [6]: %run gui-gtk.py
8 In [6]: %run gui-gtk.py
9 """
9 """
10
10
11
12 import pygtk
11 import pygtk
13 pygtk.require('2.0')
12 pygtk.require('2.0')
14 import gtk
13 import gtk
@@ -38,5 +37,3 b' try:'
38 enable_gtk()
37 enable_gtk()
39 except ImportError:
38 except ImportError:
40 gtk.main()
39 gtk.main()
41
42 #gtk.main()
@@ -1,5 +1,10 b''
1 #!/usr/bin/env python
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 To run this do:
9 To run this do:
5
10
@@ -98,7 +103,12 b' class MyApp(wx.App):'
98 frame.Show(True)
103 frame.Show(True)
99 return True
104 return True
100
105
106
101 if __name__ == '__main__':
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 app = wx.GetApp()
112 app = wx.GetApp()
103 if app is None:
113 if app is None:
104 app = MyApp(redirect=False, clearSigInt=False)
114 app = MyApp(redirect=False, clearSigInt=False)
@@ -1117,6 +1117,18 b' GUI event loop support'
1117 .. versionadded:: 0.11
1117 .. versionadded:: 0.11
1118 The ``%gui`` magic and :mod:`IPython.lib.inputhook`.
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 IPython has excellent support for working interactively with Graphical User
1132 IPython has excellent support for working interactively with Graphical User
1121 Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is
1133 Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is
1122 implemented using Python's builtin ``PyOSInputHook`` hook. This implementation
1134 implemented using Python's builtin ``PyOSInputHook`` hook. This implementation
@@ -1145,32 +1157,33 b' object, do::'
1145 For information on IPython's Matplotlib integration (and the ``pylab`` mode)
1157 For information on IPython's Matplotlib integration (and the ``pylab`` mode)
1146 see :ref:`this section <matplotlib_support>`.
1158 see :ref:`this section <matplotlib_support>`.
1147
1159
1148 For developers that want to use IPython's GUI event loop integration in
1160 For developers that want to use IPython's GUI event loop integration in the
1149 the form of a library, these capabilities are exposed in library form
1161 form of a library, these capabilities are exposed in library form in the
1150 in the :mod:`IPython.lib.inputhook`. Interested developers should see the
1162 :mod:`IPython.lib.inputhook` and :mod:`IPython.lib.guisupport` modules.
1151 module docstrings for more information, but there are a few points that
1163 Interested developers should see the module docstrings for more information,
1152 should be mentioned here.
1164 but there are a few points that should be mentioned here.
1153
1165
1154 First, the ``PyOSInputHook`` approach only works in command line settings
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 Second, when using the ``PyOSInputHook`` approach, a GUI application should
1171 Second, when using the ``PyOSInputHook`` approach, a GUI application should
1158 *not* start its event loop. Instead all of this is handled by the
1172 *not* start its event loop. Instead all of this is handled by the
1159 ``PyOSInputHook``. This means that applications that are meant to be used both
1173 ``PyOSInputHook``. This means that applications that are meant to be used both
1160 in IPython and as standalone apps need to have special code to detects how the
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
1175 application is being run. We highly recommend using IPython's support for this.
1162 :func:`enable_foo` functions for this. Here is a simple example that shows the
1176 Since the details vary slightly between toolkits, we point you to the various
1163 recommended code that should be at the bottom of a wxPython using GUI
1177 examples in our source directory :file:`docs/examples/lib` that demonstrate
1164 application::
1178 these capabilities.
1165
1179
1166 try:
1180 .. warning::
1167 from IPython.lib.inputhook import enable_wx
1181
1168 enable_wx(app)
1182 The WX version of this is currently broken. While ``--pylab=wx`` works
1169 except ImportError:
1183 fine, standalone WX apps do not. See
1170 app.MainLoop()
1184 https://github.com/ipython/ipython/issues/645 for details of our progress on
1171
1185 this issue.
1172 This pattern should be used instead of the simple ``app.MainLoop()`` code
1186
1173 that a standalone wxPython application would have.
1174
1187
1175 Third, unlike previous versions of IPython, we no longer "hijack" (replace
1188 Third, unlike previous versions of IPython, we no longer "hijack" (replace
1176 them with no-ops) the event loops. This is done to allow applications that
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