Show More
@@ -8,7 +8,9 b' In [6]: %run gui-wx.py' | |||
|
8 | 8 | |
|
9 | 9 | Ref: Modified from wxPython source code wxPython/samples/simple/simple.py |
|
10 | 10 | |
|
11 |
This example can only be run once in a given IPython session |
|
|
11 | This example can only be run once in a given IPython session because when | |
|
12 | the frame is closed, wx goes through its shutdown sequence, killing further | |
|
13 | attempts. I am sure someone who knows wx can fix this issue. | |
|
12 | 14 | """ |
|
13 | 15 | |
|
14 | 16 | import wx |
@@ -1382,7 +1382,7 b' IPython has excellent support for working interactively with Graphical User' | |||
|
1382 | 1382 | Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is |
|
1383 | 1383 | implemented using Python's builtin ``PyOSInputHook`` hook. This implementation |
|
1384 | 1384 | is extremely robust compared to our previous threaded based version. The |
|
1385 | advantages of | |
|
1385 | advantages of this are: | |
|
1386 | 1386 | |
|
1387 | 1387 | * GUIs can be enabled and disabled dynamically at runtime. |
|
1388 | 1388 | * The active GUI can be switched dynamically at runtime. |
@@ -1399,7 +1399,7 b' With no arguments, ``%gui`` removes all GUI support. Valid ``GUINAME``' | |||
|
1399 | 1399 | arguments are ``wx``, ``qt4``, ``gtk`` and ``tk``. The ``-a`` option will |
|
1400 | 1400 | create and return a running application object for the selected GUI toolkit. |
|
1401 | 1401 | |
|
1402 |
Th |
|
|
1402 | Thus, to use wxPython interactively and create a running :class:`wx.App` | |
|
1403 | 1403 | object, do:: |
|
1404 | 1404 | |
|
1405 | 1405 | %gui -a wx |
@@ -1408,11 +1408,38 b" For information on IPython's Matplotlib integration (and the ``pylab`` mode)" | |||
|
1408 | 1408 | see :ref:`this section <matplotlib_support>`. |
|
1409 | 1409 | |
|
1410 | 1410 | For developers that want to use IPython's GUI event loop integration in |
|
1411 | the form of a library, the capabilities are exposed in library form | |
|
1411 | the form of a library, these capabilities are exposed in library form | |
|
1412 | 1412 | in the :mod:`IPython.lib.inputhook`. Interested developers should see the |
|
1413 |
module docstrings for more information |
|
|
1414 | ||
|
1415 | In addition, we also have a number of examples in our source directory | |
|
1413 | module docstrings for more information, but there are a few points that | |
|
1414 | should be mentioned here. | |
|
1415 | ||
|
1416 | First, the ``PyOSInputHook`` approach only works in command line settings | |
|
1417 | where readline is activated. | |
|
1418 | ||
|
1419 | Second, when using the ``PyOSInputHook`` approach, a GUI application should | |
|
1420 | *not* start its event loop. Instead all of this is handled by the | |
|
1421 | ``PyOSInputHook``. This means that applications that are meant to be used both | |
|
1422 | in IPython and as standalone apps need to have special code to detects how the | |
|
1423 | application is being run. We highly recommend using IPython's | |
|
1424 | :func:`appstart_` functions for this. Here is a simple example that shows the | |
|
1425 | recommended code that should be at the bottom of a wxPython using GUI | |
|
1426 | application:: | |
|
1427 | ||
|
1428 | try: | |
|
1429 | from IPython import appstart_wx | |
|
1430 | appstart_wx(app) | |
|
1431 | except ImportError: | |
|
1432 | app.MainLoop() | |
|
1433 | ||
|
1434 | This pattern should be used instead of the simple ``app.MainLoop()`` code | |
|
1435 | that a standalone wxPython application would have. | |
|
1436 | ||
|
1437 | Third, unlike previous versions of IPython, we no longer "hijack" (replace | |
|
1438 | them with no-ops) the event loops. This is done to allow applications that | |
|
1439 | actually need to run the real event loops to do so. This is often needed to | |
|
1440 | process pending events at critical points. | |
|
1441 | ||
|
1442 | Finally, we also have a number of examples in our source directory | |
|
1416 | 1443 | :file:`docs/examples/lib` that demonstrate these capabilities. |
|
1417 | 1444 | |
|
1418 | 1445 | .. _matplotlib_support: |
General Comments 0
You need to be logged in to leave comments.
Login now