##// END OF EJS Templates
Make print syntax in GUI integration examples Python 3 compatible.
Thomas Kluyver -
Show More
@@ -5,10 +5,11 b' 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.
@@ -23,18 +24,18 b' y = 2'
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!')
@@ -14,7 +14,7 b' 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
@@ -20,7 +20,7 b' class MyApp:'
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
@@ -69,12 +69,12 b' class MyFrame(wx.Frame):'
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):
@@ -82,7 +82,7 b' class MyApp(wx.App):'
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
@@ -96,7 +96,7 b" if __name__ == '__main__':"
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:
@@ -41,10 +41,10 b' class InternalIPKernel(object):'
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):
@@ -90,7 +90,7 b' class MyFrame(wx.Frame, InternalIPKernel):'
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()
General Comments 0
You need to be logged in to leave comments. Login now