##// END OF EJS Templates
Make print syntax in GUI integration examples Python 3 compatible.
Thomas Kluyver -
Show More
@@ -1,40 +1,41 b''
1 """A simple interactive demo to illustrate the use of IPython's Demo class.
1 """A simple interactive demo to illustrate the use of IPython's Demo class.
2
2
3 Any python script can be run as a demo, but that does little more than showing
3 Any python script can be run as a demo, but that does little more than showing
4 it on-screen, syntax-highlighted in one shot. If you add a little simple
4 it on-screen, syntax-highlighted in one shot. If you add a little simple
5 markup, you can stop at specified intervals and return to the ipython prompt,
5 markup, you can stop at specified intervals and return to the ipython prompt,
6 resuming execution later.
6 resuming execution later.
7 """
7 """
8 from __future__ import print_function
8
9
9 print 'Hello, welcome to an interactive IPython demo.'
10 print('Hello, welcome to an interactive IPython demo.')
10 print 'Executing this block should require confirmation before proceeding,'
11 print('Executing this block should require confirmation before proceeding,')
11 print 'unless auto_all has been set to true in the demo object'
12 print('unless auto_all has been set to true in the demo object')
12
13
13 # The mark below defines a block boundary, which is a point where IPython will
14 # The mark below defines a block boundary, which is a point where IPython will
14 # stop execution and return to the interactive prompt.
15 # stop execution and return to the interactive prompt.
15 # Note that in actual interactive execution,
16 # Note that in actual interactive execution,
16 # <demo> --- stop ---
17 # <demo> --- stop ---
17
18
18 x = 1
19 x = 1
19 y = 2
20 y = 2
20
21
21 # <demo> --- stop ---
22 # <demo> --- stop ---
22
23
23 # the mark below makes this block as silent
24 # the mark below makes this block as silent
24 # <demo> silent
25 # <demo> silent
25
26
26 print 'This is a silent block, which gets executed but not printed.'
27 print('This is a silent block, which gets executed but not printed.')
27
28
28 # <demo> --- stop ---
29 # <demo> --- stop ---
29 # <demo> auto
30 # <demo> auto
30 print 'This is an automatic block.'
31 print('This is an automatic block.')
31 print 'It is executed without asking for confirmation, but printed.'
32 print('It is executed without asking for confirmation, but printed.')
32 z = x+y
33 z = x+y
33
34
34 print 'z=',x
35 print('z=',x)
35
36
36 # <demo> --- stop ---
37 # <demo> --- stop ---
37 # This is just another normal block.
38 # This is just another normal block.
38 print 'z is now:', z
39 print('z is now:', z)
39
40
40 print 'bye!'
41 print('bye!')
@@ -1,39 +1,39 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Simple GTK example to manually test event loop integration.
2 """Simple GTK example to manually test event loop integration.
3
3
4 This is meant to run tests manually in ipython as:
4 This is meant to run tests manually in ipython as:
5
5
6 In [5]: %gui gtk
6 In [5]: %gui gtk
7
7
8 In [6]: %run gui-gtk.py
8 In [6]: %run gui-gtk.py
9 """
9 """
10
10
11 import pygtk
11 import pygtk
12 pygtk.require('2.0')
12 pygtk.require('2.0')
13 import gtk
13 import gtk
14
14
15
15
16 def hello_world(wigdet, data=None):
16 def hello_world(wigdet, data=None):
17 print "Hello World"
17 print("Hello World")
18
18
19 def delete_event(widget, event, data=None):
19 def delete_event(widget, event, data=None):
20 return False
20 return False
21
21
22 def destroy(widget, data=None):
22 def destroy(widget, data=None):
23 gtk.main_quit()
23 gtk.main_quit()
24
24
25 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
25 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
26 window.connect("delete_event", delete_event)
26 window.connect("delete_event", delete_event)
27 window.connect("destroy", destroy)
27 window.connect("destroy", destroy)
28 button = gtk.Button("Hello World")
28 button = gtk.Button("Hello World")
29 button.connect("clicked", hello_world, None)
29 button.connect("clicked", hello_world, None)
30
30
31 window.add(button)
31 window.add(button)
32 button.show()
32 button.show()
33 window.show()
33 window.show()
34
34
35 try:
35 try:
36 from IPython.lib.inputhook import enable_gtk
36 from IPython.lib.inputhook import enable_gtk
37 enable_gtk()
37 enable_gtk()
38 except ImportError:
38 except ImportError:
39 gtk.main()
39 gtk.main()
@@ -1,32 +1,32 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Simple Tk example to manually test event loop integration.
2 """Simple Tk example to manually test event loop integration.
3
3
4 This is meant to run tests manually in ipython as:
4 This is meant to run tests manually in ipython as:
5
5
6 In [5]: %gui tk
6 In [5]: %gui tk
7
7
8 In [6]: %run gui-tk.py
8 In [6]: %run gui-tk.py
9 """
9 """
10
10
11 from Tkinter import *
11 from Tkinter import *
12
12
13 class MyApp:
13 class MyApp:
14
14
15 def __init__(self, root):
15 def __init__(self, root):
16 frame = Frame(root)
16 frame = Frame(root)
17 frame.pack()
17 frame.pack()
18
18
19 self.button = Button(frame, text="Hello", command=self.hello_world)
19 self.button = Button(frame, text="Hello", command=self.hello_world)
20 self.button.pack(side=LEFT)
20 self.button.pack(side=LEFT)
21
21
22 def hello_world(self):
22 def hello_world(self):
23 print "Hello World!"
23 print("Hello World!")
24
24
25 root = Tk()
25 root = Tk()
26
26
27 app = MyApp(root)
27 app = MyApp(root)
28
28
29 try:
29 try:
30 from IPython.lib.inputhook import enable_tk; enable_tk(root)
30 from IPython.lib.inputhook import enable_tk; enable_tk(root)
31 except ImportError:
31 except ImportError:
32 root.mainloop()
32 root.mainloop()
@@ -1,106 +1,106 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """
2 """
3 A Simple wx example to test IPython's event loop integration.
3 A Simple wx example to test IPython's event loop integration.
4
4
5 To run this do:
5 To run this do:
6
6
7 In [5]: %gui wx # or start IPython with '--gui wx' or '--pylab wx'
7 In [5]: %gui wx # or start IPython with '--gui wx' or '--pylab wx'
8
8
9 In [6]: %run gui-wx.py
9 In [6]: %run gui-wx.py
10
10
11 Ref: Modified from wxPython source code wxPython/samples/simple/simple.py
11 Ref: Modified from wxPython source code wxPython/samples/simple/simple.py
12 """
12 """
13
13
14 import wx
14 import wx
15
15
16
16
17 class MyFrame(wx.Frame):
17 class MyFrame(wx.Frame):
18 """
18 """
19 This is MyFrame. It just shows a few controls on a wxPanel,
19 This is MyFrame. It just shows a few controls on a wxPanel,
20 and has a simple menu.
20 and has a simple menu.
21 """
21 """
22 def __init__(self, parent, title):
22 def __init__(self, parent, title):
23 wx.Frame.__init__(self, parent, -1, title,
23 wx.Frame.__init__(self, parent, -1, title,
24 pos=(150, 150), size=(350, 200))
24 pos=(150, 150), size=(350, 200))
25
25
26 # Create the menubar
26 # Create the menubar
27 menuBar = wx.MenuBar()
27 menuBar = wx.MenuBar()
28
28
29 # and a menu
29 # and a menu
30 menu = wx.Menu()
30 menu = wx.Menu()
31
31
32 # add an item to the menu, using \tKeyName automatically
32 # add an item to the menu, using \tKeyName automatically
33 # creates an accelerator, the third param is some help text
33 # creates an accelerator, the third param is some help text
34 # that will show up in the statusbar
34 # that will show up in the statusbar
35 menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
35 menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
36
36
37 # bind the menu event to an event handler
37 # bind the menu event to an event handler
38 self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
38 self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
39
39
40 # and put the menu on the menubar
40 # and put the menu on the menubar
41 menuBar.Append(menu, "&File")
41 menuBar.Append(menu, "&File")
42 self.SetMenuBar(menuBar)
42 self.SetMenuBar(menuBar)
43
43
44 self.CreateStatusBar()
44 self.CreateStatusBar()
45
45
46 # Now create the Panel to put the other controls on.
46 # Now create the Panel to put the other controls on.
47 panel = wx.Panel(self)
47 panel = wx.Panel(self)
48
48
49 # and a few controls
49 # and a few controls
50 text = wx.StaticText(panel, -1, "Hello World!")
50 text = wx.StaticText(panel, -1, "Hello World!")
51 text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
51 text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
52 text.SetSize(text.GetBestSize())
52 text.SetSize(text.GetBestSize())
53 btn = wx.Button(panel, -1, "Close")
53 btn = wx.Button(panel, -1, "Close")
54 funbtn = wx.Button(panel, -1, "Just for fun...")
54 funbtn = wx.Button(panel, -1, "Just for fun...")
55
55
56 # bind the button events to handlers
56 # bind the button events to handlers
57 self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, btn)
57 self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, btn)
58 self.Bind(wx.EVT_BUTTON, self.OnFunButton, funbtn)
58 self.Bind(wx.EVT_BUTTON, self.OnFunButton, funbtn)
59
59
60 # Use a sizer to layout the controls, stacked vertically and with
60 # Use a sizer to layout the controls, stacked vertically and with
61 # a 10 pixel border around each
61 # a 10 pixel border around each
62 sizer = wx.BoxSizer(wx.VERTICAL)
62 sizer = wx.BoxSizer(wx.VERTICAL)
63 sizer.Add(text, 0, wx.ALL, 10)
63 sizer.Add(text, 0, wx.ALL, 10)
64 sizer.Add(btn, 0, wx.ALL, 10)
64 sizer.Add(btn, 0, wx.ALL, 10)
65 sizer.Add(funbtn, 0, wx.ALL, 10)
65 sizer.Add(funbtn, 0, wx.ALL, 10)
66 panel.SetSizer(sizer)
66 panel.SetSizer(sizer)
67 panel.Layout()
67 panel.Layout()
68
68
69
69
70 def OnTimeToClose(self, evt):
70 def OnTimeToClose(self, evt):
71 """Event handler for the button click."""
71 """Event handler for the button click."""
72 print "See ya later!"
72 print("See ya later!")
73 self.Close()
73 self.Close()
74
74
75 def OnFunButton(self, evt):
75 def OnFunButton(self, evt):
76 """Event handler for the button click."""
76 """Event handler for the button click."""
77 print "Having fun yet?"
77 print("Having fun yet?")
78
78
79
79
80 class MyApp(wx.App):
80 class MyApp(wx.App):
81 def OnInit(self):
81 def OnInit(self):
82 frame = MyFrame(None, "Simple wxPython App")
82 frame = MyFrame(None, "Simple wxPython App")
83 self.SetTopWindow(frame)
83 self.SetTopWindow(frame)
84
84
85 print "Print statements go to this stdout window by default."
85 print("Print statements go to this stdout window by default.")
86
86
87 frame.Show(True)
87 frame.Show(True)
88 return True
88 return True
89
89
90
90
91 if __name__ == '__main__':
91 if __name__ == '__main__':
92
92
93 app = wx.GetApp()
93 app = wx.GetApp()
94 if app is None:
94 if app is None:
95 app = MyApp(redirect=False, clearSigInt=False)
95 app = MyApp(redirect=False, clearSigInt=False)
96 else:
96 else:
97 frame = MyFrame(None, "Simple wxPython App")
97 frame = MyFrame(None, "Simple wxPython App")
98 app.SetTopWindow(frame)
98 app.SetTopWindow(frame)
99 print "Print statements go to this stdout window by default."
99 print("Print statements go to this stdout window by default.")
100 frame.Show(True)
100 frame.Show(True)
101
101
102 try:
102 try:
103 from IPython.lib.inputhook import enable_wx
103 from IPython.lib.inputhook import enable_wx
104 enable_wx(app)
104 enable_wx(app)
105 except ImportError:
105 except ImportError:
106 app.MainLoop()
106 app.MainLoop()
@@ -1,59 +1,59 b''
1 #-----------------------------------------------------------------------------
1 #-----------------------------------------------------------------------------
2 # Imports
2 # Imports
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4
4
5 import subprocess
5 import subprocess
6 import sys
6 import sys
7
7
8 from IPython.lib.kernel import connect_qtconsole
8 from IPython.lib.kernel import connect_qtconsole
9 from IPython.zmq.ipkernel import IPKernelApp
9 from IPython.zmq.ipkernel import IPKernelApp
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Functions and classes
12 # Functions and classes
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 def pylab_kernel(gui):
14 def pylab_kernel(gui):
15 """Launch and return an IPython kernel with pylab support for the desired gui
15 """Launch and return an IPython kernel with pylab support for the desired gui
16 """
16 """
17 kernel = IPKernelApp.instance()
17 kernel = IPKernelApp.instance()
18 kernel.initialize(['python', '--pylab=%s' % gui,
18 kernel.initialize(['python', '--pylab=%s' % gui,
19 #'--log-level=10'
19 #'--log-level=10'
20 ])
20 ])
21 return kernel
21 return kernel
22
22
23
23
24 class InternalIPKernel(object):
24 class InternalIPKernel(object):
25
25
26 def init_ipkernel(self, backend):
26 def init_ipkernel(self, backend):
27 # Start IPython kernel with GUI event loop and pylab support
27 # Start IPython kernel with GUI event loop and pylab support
28 self.ipkernel = pylab_kernel(backend)
28 self.ipkernel = pylab_kernel(backend)
29 # To create and track active qt consoles
29 # To create and track active qt consoles
30 self.consoles = []
30 self.consoles = []
31
31
32 # This application will also act on the shell user namespace
32 # This application will also act on the shell user namespace
33 self.namespace = self.ipkernel.shell.user_ns
33 self.namespace = self.ipkernel.shell.user_ns
34 # Keys present at startup so we don't print the entire pylab/numpy
34 # Keys present at startup so we don't print the entire pylab/numpy
35 # namespace when the user clicks the 'namespace' button
35 # namespace when the user clicks the 'namespace' button
36 self._init_keys = set(self.namespace.keys())
36 self._init_keys = set(self.namespace.keys())
37
37
38 # Example: a variable that will be seen by the user in the shell, and
38 # Example: a variable that will be seen by the user in the shell, and
39 # that the GUI modifies (the 'Counter++' button increments it):
39 # that the GUI modifies (the 'Counter++' button increments it):
40 self.namespace['app_counter'] = 0
40 self.namespace['app_counter'] = 0
41 #self.namespace['ipkernel'] = self.ipkernel # dbg
41 #self.namespace['ipkernel'] = self.ipkernel # dbg
42
42
43 def print_namespace(self, evt=None):
43 def print_namespace(self, evt=None):
44 print "\n***Variables in User namespace***"
44 print("\n***Variables in User namespace***")
45 for k, v in self.namespace.iteritems():
45 for k, v in self.namespace.iteritems():
46 if k not in self._init_keys and not k.startswith('_'):
46 if k not in self._init_keys and not k.startswith('_'):
47 print '%s -> %r' % (k, v)
47 print('%s -> %r' % (k, v))
48 sys.stdout.flush()
48 sys.stdout.flush()
49
49
50 def new_qt_console(self, evt=None):
50 def new_qt_console(self, evt=None):
51 """start a new qtconsole connected to our kernel"""
51 """start a new qtconsole connected to our kernel"""
52 return connect_qtconsole(self.ipkernel.connection_file, profile=self.ipkernel.profile)
52 return connect_qtconsole(self.ipkernel.connection_file, profile=self.ipkernel.profile)
53
53
54 def count(self, evt=None):
54 def count(self, evt=None):
55 self.namespace['app_counter'] += 1
55 self.namespace['app_counter'] += 1
56
56
57 def cleanup_consoles(self, evt=None):
57 def cleanup_consoles(self, evt=None):
58 for c in self.consoles:
58 for c in self.consoles:
59 c.kill()
59 c.kill()
@@ -1,119 +1,119 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Example integrating an IPython kernel into a GUI App.
2 """Example integrating an IPython kernel into a GUI App.
3
3
4 This trivial GUI application internally starts an IPython kernel, to which Qt
4 This trivial GUI application internally starts an IPython kernel, to which Qt
5 consoles can be connected either by the user at the command line or started
5 consoles can be connected either by the user at the command line or started
6 from the GUI itself, via a button. The GUI can also manipulate one variable in
6 from the GUI itself, via a button. The GUI can also manipulate one variable in
7 the kernel's namespace, and print the namespace to the console.
7 the kernel's namespace, and print the namespace to the console.
8
8
9 Play with it by running the script and then opening one or more consoles, and
9 Play with it by running the script and then opening one or more consoles, and
10 pushing the 'Counter++' and 'Namespace' buttons.
10 pushing the 'Counter++' and 'Namespace' buttons.
11
11
12 Upon exit, it should automatically close all consoles opened from the GUI.
12 Upon exit, it should automatically close all consoles opened from the GUI.
13
13
14 Consoles attached separately from a terminal will not be terminated, though
14 Consoles attached separately from a terminal will not be terminated, though
15 they will notice that their kernel died.
15 they will notice that their kernel died.
16
16
17 Ref: Modified from wxPython source code wxPython/samples/simple/simple.py
17 Ref: Modified from wxPython source code wxPython/samples/simple/simple.py
18 """
18 """
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Imports
20 # Imports
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 import sys
22 import sys
23
23
24 import wx
24 import wx
25
25
26 from internal_ipkernel import InternalIPKernel
26 from internal_ipkernel import InternalIPKernel
27
27
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29 # Functions and classes
29 # Functions and classes
30 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
31
31
32 class MyFrame(wx.Frame, InternalIPKernel):
32 class MyFrame(wx.Frame, InternalIPKernel):
33 """
33 """
34 This is MyFrame. It just shows a few controls on a wxPanel,
34 This is MyFrame. It just shows a few controls on a wxPanel,
35 and has a simple menu.
35 and has a simple menu.
36 """
36 """
37
37
38 def __init__(self, parent, title):
38 def __init__(self, parent, title):
39 wx.Frame.__init__(self, parent, -1, title,
39 wx.Frame.__init__(self, parent, -1, title,
40 pos=(150, 150), size=(350, 285))
40 pos=(150, 150), size=(350, 285))
41
41
42 # Create the menubar
42 # Create the menubar
43 menuBar = wx.MenuBar()
43 menuBar = wx.MenuBar()
44
44
45 # and a menu
45 # and a menu
46 menu = wx.Menu()
46 menu = wx.Menu()
47
47
48 # add an item to the menu, using \tKeyName automatically
48 # add an item to the menu, using \tKeyName automatically
49 # creates an accelerator, the third param is some help text
49 # creates an accelerator, the third param is some help text
50 # that will show up in the statusbar
50 # that will show up in the statusbar
51 menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
51 menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
52
52
53 # bind the menu event to an event handler
53 # bind the menu event to an event handler
54 self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
54 self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
55
55
56 # and put the menu on the menubar
56 # and put the menu on the menubar
57 menuBar.Append(menu, "&File")
57 menuBar.Append(menu, "&File")
58 self.SetMenuBar(menuBar)
58 self.SetMenuBar(menuBar)
59
59
60 self.CreateStatusBar()
60 self.CreateStatusBar()
61
61
62 # Now create the Panel to put the other controls on.
62 # Now create the Panel to put the other controls on.
63 panel = wx.Panel(self)
63 panel = wx.Panel(self)
64
64
65 # and a few controls
65 # and a few controls
66 text = wx.StaticText(panel, -1, "Hello World!")
66 text = wx.StaticText(panel, -1, "Hello World!")
67 text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
67 text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
68 text.SetSize(text.GetBestSize())
68 text.SetSize(text.GetBestSize())
69 qtconsole_btn = wx.Button(panel, -1, "Qt Console")
69 qtconsole_btn = wx.Button(panel, -1, "Qt Console")
70 ns_btn = wx.Button(panel, -1, "Namespace")
70 ns_btn = wx.Button(panel, -1, "Namespace")
71 count_btn = wx.Button(panel, -1, "Count++")
71 count_btn = wx.Button(panel, -1, "Count++")
72 close_btn = wx.Button(panel, -1, "Quit")
72 close_btn = wx.Button(panel, -1, "Quit")
73
73
74 # bind the button events to handlers
74 # bind the button events to handlers
75 self.Bind(wx.EVT_BUTTON, self.new_qt_console, qtconsole_btn)
75 self.Bind(wx.EVT_BUTTON, self.new_qt_console, qtconsole_btn)
76 self.Bind(wx.EVT_BUTTON, self.print_namespace, ns_btn)
76 self.Bind(wx.EVT_BUTTON, self.print_namespace, ns_btn)
77 self.Bind(wx.EVT_BUTTON, self.count, count_btn)
77 self.Bind(wx.EVT_BUTTON, self.count, count_btn)
78 self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, close_btn)
78 self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, close_btn)
79
79
80 # Use a sizer to layout the controls, stacked vertically and with
80 # Use a sizer to layout the controls, stacked vertically and with
81 # a 10 pixel border around each
81 # a 10 pixel border around each
82 sizer = wx.BoxSizer(wx.VERTICAL)
82 sizer = wx.BoxSizer(wx.VERTICAL)
83 for ctrl in [text, qtconsole_btn, ns_btn, count_btn, close_btn]:
83 for ctrl in [text, qtconsole_btn, ns_btn, count_btn, close_btn]:
84 sizer.Add(ctrl, 0, wx.ALL, 10)
84 sizer.Add(ctrl, 0, wx.ALL, 10)
85 panel.SetSizer(sizer)
85 panel.SetSizer(sizer)
86 panel.Layout()
86 panel.Layout()
87
87
88 # Start the IPython kernel with gui support
88 # Start the IPython kernel with gui support
89 self.init_ipkernel('wx')
89 self.init_ipkernel('wx')
90
90
91 def OnTimeToClose(self, evt):
91 def OnTimeToClose(self, evt):
92 """Event handler for the button click."""
92 """Event handler for the button click."""
93 print "See ya later!"
93 print("See ya later!")
94 sys.stdout.flush()
94 sys.stdout.flush()
95 self.cleanup_consoles(evt)
95 self.cleanup_consoles(evt)
96 self.Close()
96 self.Close()
97 # Not sure why, but our IPython kernel seems to prevent normal WX
97 # Not sure why, but our IPython kernel seems to prevent normal WX
98 # shutdown, so an explicit exit() call is needed.
98 # shutdown, so an explicit exit() call is needed.
99 sys.exit()
99 sys.exit()
100
100
101
101
102 class MyApp(wx.App):
102 class MyApp(wx.App):
103 def OnInit(self):
103 def OnInit(self):
104 frame = MyFrame(None, "Simple wxPython App")
104 frame = MyFrame(None, "Simple wxPython App")
105 self.SetTopWindow(frame)
105 self.SetTopWindow(frame)
106 frame.Show(True)
106 frame.Show(True)
107 self.ipkernel = frame.ipkernel
107 self.ipkernel = frame.ipkernel
108 return True
108 return True
109
109
110 #-----------------------------------------------------------------------------
110 #-----------------------------------------------------------------------------
111 # Main script
111 # Main script
112 #-----------------------------------------------------------------------------
112 #-----------------------------------------------------------------------------
113
113
114 if __name__ == '__main__':
114 if __name__ == '__main__':
115 app = MyApp(redirect=False, clearSigInt=False)
115 app = MyApp(redirect=False, clearSigInt=False)
116
116
117 # Very important, IPython-specific step: this gets GUI event loop
117 # Very important, IPython-specific step: this gets GUI event loop
118 # integration going, and it replaces calling app.MainLoop()
118 # integration going, and it replaces calling app.MainLoop()
119 app.ipkernel.start()
119 app.ipkernel.start()
General Comments 0
You need to be logged in to leave comments. Login now