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 |
|
General Comments 0
You need to be logged in to leave comments.
Login now