Show More
@@ -1,30 +1,14 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | """ |
|
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 | A Simple wx example to test IPython's event loop integration. | |
8 |
|
4 | |||
9 | To run this do: |
|
5 | To run this do: | |
10 |
|
6 | |||
11 | In [5]: %gui wx |
|
7 | In [5]: %gui wx # or start IPython with '--gui wx' or '--pylab wx' | |
12 |
|
8 | |||
13 | In [6]: %run gui-wx.py |
|
9 | In [6]: %run gui-wx.py | |
14 |
|
10 | |||
15 | Ref: Modified from wxPython source code wxPython/samples/simple/simple.py |
|
11 | Ref: Modified from wxPython source code wxPython/samples/simple/simple.py | |
16 |
|
||||
17 | This example can only be run once in a given IPython session because when |
|
|||
18 | the frame is closed, wx goes through its shutdown sequence, killing further |
|
|||
19 | attempts. I am sure someone who knows wx can fix this issue. |
|
|||
20 |
|
||||
21 | Furthermore, once this example is run, the Wx event loop is mostly dead, so |
|
|||
22 | even other new uses of Wx may not work correctly. If you know how to better |
|
|||
23 | handle this, please contact the ipython developers and let us know. |
|
|||
24 |
|
||||
25 | Note however that we will work with the Matplotlib and Enthought developers so |
|
|||
26 | that the main interactive uses of Wx we are aware of, namely these tools, will |
|
|||
27 | continue to work well with IPython interactively. |
|
|||
28 | """ |
|
12 | """ | |
29 |
|
13 | |||
30 | import wx |
|
14 | import wx | |
@@ -105,17 +89,18 b' class MyApp(wx.App):' | |||||
105 |
|
89 | |||
106 |
|
90 | |||
107 | if __name__ == '__main__': |
|
91 | 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 |
|
92 | |||
112 | app = wx.GetApp() |
|
93 | app = wx.GetApp() | |
113 | if app is None: |
|
94 | if app is None: | |
114 | app = MyApp(redirect=False, clearSigInt=False) |
|
95 | app = MyApp(redirect=False, clearSigInt=False) | |
|
96 | else: | |||
|
97 | frame = MyFrame(None, "Simple wxPython App") | |||
|
98 | app.SetTopWindow(frame) | |||
|
99 | print "Print statements go to this stdout window by default." | |||
|
100 | frame.Show(True) | |||
115 |
|
101 | |||
116 | try: |
|
102 | try: | |
117 | from IPython.lib.inputhook import enable_wx |
|
103 | from IPython.lib.inputhook import enable_wx | |
118 | enable_wx(app) |
|
104 | enable_wx(app) | |
119 | except ImportError: |
|
105 | except ImportError: | |
120 | app.MainLoop() |
|
106 | app.MainLoop() | |
121 |
|
@@ -870,14 +870,6 b' Since the details vary slightly between toolkits, we point you to the various' | |||||
870 | examples in our source directory :file:`docs/examples/lib` that demonstrate |
|
870 | examples in our source directory :file:`docs/examples/lib` that demonstrate | |
871 | these capabilities. |
|
871 | these capabilities. | |
872 |
|
872 | |||
873 | .. warning:: |
|
|||
874 |
|
||||
875 | The WX version of this is currently broken. While ``--pylab=wx`` works |
|
|||
876 | fine, standalone WX apps do not. See |
|
|||
877 | https://github.com/ipython/ipython/issues/645 for details of our progress on |
|
|||
878 | this issue. |
|
|||
879 |
|
||||
880 |
|
||||
881 | Third, unlike previous versions of IPython, we no longer "hijack" (replace |
|
873 | Third, unlike previous versions of IPython, we no longer "hijack" (replace | |
882 | them with no-ops) the event loops. This is done to allow applications that |
|
874 | them with no-ops) the event loops. This is done to allow applications that | |
883 | actually need to run the real event loops to do so. This is often needed to |
|
875 | actually need to run the real event loops to do so. This is often needed to | |
@@ -938,9 +930,11 b' Matlab program.' | |||||
938 |
|
930 | |||
939 | To start IPython with matplotlib support, use the ``--pylab`` switch. If no |
|
931 | To start IPython with matplotlib support, use the ``--pylab`` switch. If no | |
940 | arguments are given, IPython will automatically detect your choice of |
|
932 | arguments are given, IPython will automatically detect your choice of | |
941 | matplotlib backend. You can also request a specific backend with |
|
933 | matplotlib backend. You can also request a specific backend with ``--pylab | |
942 |
|
|
934 | backend``, where ``backend`` must be one of: 'tk', 'qt', 'wx', 'gtk', 'osx'. | |
943 | 'osx'. |
|
935 | In the web notebook and Qt console, 'inline' is also a valid backend value, | |
|
936 | which produces static figures inlined inside the application window instead of | |||
|
937 | matplotlib's interactive figures that live in separate windows. | |||
944 |
|
938 | |||
945 | .. _Matplotlib: http://matplotlib.sourceforge.net |
|
939 | .. _Matplotlib: http://matplotlib.sourceforge.net | |
946 |
|
940 |
General Comments 0
You need to be logged in to leave comments.
Login now