##// 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 5 markup, you can stop at specified intervals and return to the ipython prompt,
6 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 'Executing this block should require confirmation before proceeding,'
11 print 'unless auto_all has been set to true in the demo object'
10 print('Hello, welcome to an interactive IPython demo.')
11 print('Executing this block should require confirmation before proceeding,')
12 print('unless auto_all has been set to true in the demo object')
12 13
13 14 # The mark below defines a block boundary, which is a point where IPython will
14 15 # stop execution and return to the interactive prompt.
@@ -23,18 +24,18 b' y = 2'
23 24 # the mark below makes this block as silent
24 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 29 # <demo> --- stop ---
29 30 # <demo> auto
30 print 'This is an automatic block.'
31 print 'It is executed without asking for confirmation, but printed.'
31 print('This is an automatic block.')
32 print('It is executed without asking for confirmation, but printed.')
32 33 z = x+y
33 34
34 print 'z=',x
35 print('z=',x)
35 36
36 37 # <demo> --- stop ---
37 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 16 def hello_world(wigdet, data=None):
17 print "Hello World"
17 print("Hello World")
18 18
19 19 def delete_event(widget, event, data=None):
20 20 return False
@@ -20,7 +20,7 b' class MyApp:'
20 20 self.button.pack(side=LEFT)
21 21
22 22 def hello_world(self):
23 print "Hello World!"
23 print("Hello World!")
24 24
25 25 root = Tk()
26 26
@@ -69,12 +69,12 b' class MyFrame(wx.Frame):'
69 69
70 70 def OnTimeToClose(self, evt):
71 71 """Event handler for the button click."""
72 print "See ya later!"
72 print("See ya later!")
73 73 self.Close()
74 74
75 75 def OnFunButton(self, evt):
76 76 """Event handler for the button click."""
77 print "Having fun yet?"
77 print("Having fun yet?")
78 78
79 79
80 80 class MyApp(wx.App):
@@ -82,7 +82,7 b' class MyApp(wx.App):'
82 82 frame = MyFrame(None, "Simple wxPython App")
83 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 87 frame.Show(True)
88 88 return True
@@ -96,7 +96,7 b" if __name__ == '__main__':"
96 96 else:
97 97 frame = MyFrame(None, "Simple wxPython App")
98 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 100 frame.Show(True)
101 101
102 102 try:
@@ -41,10 +41,10 b' class InternalIPKernel(object):'
41 41 #self.namespace['ipkernel'] = self.ipkernel # dbg
42 42
43 43 def print_namespace(self, evt=None):
44 print "\n***Variables in User namespace***"
44 print("\n***Variables in User namespace***")
45 45 for k, v in self.namespace.iteritems():
46 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 48 sys.stdout.flush()
49 49
50 50 def new_qt_console(self, evt=None):
@@ -90,7 +90,7 b' class MyFrame(wx.Frame, InternalIPKernel):'
90 90
91 91 def OnTimeToClose(self, evt):
92 92 """Event handler for the button click."""
93 print "See ya later!"
93 print("See ya later!")
94 94 sys.stdout.flush()
95 95 self.cleanup_consoles(evt)
96 96 self.Close()
General Comments 0
You need to be logged in to leave comments. Login now