Skip to content

Commit d1ae136

Browse files
committed
Conflicts: Examples/wxpython/basic_app_3.py Examples/wxpython/basic_app_4.py Examples/wxpython/basic_app_5.py
2 parents 2ff0dae + 91dd68b commit d1ae136

File tree

16 files changed

+154
-148
lines changed

16 files changed

+154
-148
lines changed

Examples/wxpython/address_book/address_book_app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def __init__(self, add_book, *args, **kwargs):
6363

6464
self.SetMenuBar(menuBar)
6565

66-
def next(self):
66+
def __next__(self):
6767
"""
6868
move to the next record in the address book
6969
"""
7070
try:
7171
self.entryPanel.entry = self.add_book.book[self.current_index+1]
7272
self.current_index+=1
7373
except IndexError:
74-
print "At end of records...."
74+
print("At end of records....")
7575

7676
def previous(self):
7777
"""
@@ -100,20 +100,20 @@ def onOpen(self, evt=None):
100100
if dlg.ShowModal() == wx.ID_OK:
101101
# This returns a Python list of files that were selected.
102102
path = dlg.GetPath()
103-
print "I'd be opening file in onOpen ", path
103+
print("I'd be opening file in onOpen ", path)
104104
self.add_book.load_from_file(filename=path)
105105
else :
106-
print "The file dialog was canceled"
106+
print("The file dialog was canceled")
107107
dlg.Destroy()
108108

109109

110110
def onClose(self, evt=None):
111-
print "close menu selected"
111+
print("close menu selected")
112112
self.add_book.close()
113113

114114
def onExit(self, evt=None):
115-
print "Exit the program here"
116-
print "The event passed to onExit is type ", type(evt),
115+
print("Exit the program here")
116+
print("The event passed to onExit is type ", type(evt), end=' ')
117117
self.Close()
118118

119119

Examples/wxpython/address_book/address_book_data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def new_record(self):
3636
def save_to_file(self, filename=None):
3737
if filename is not None :
3838
self.filename = filename
39-
json.dump(self.book, open(self.filename, 'wb'), indent=4 )
39+
json.dump(self.book, open(self.filename, 'w'), indent=4 )
4040

4141
def load_from_file(self, filename=None):
4242
if filename is not None :
4343
self.filename = filename
44-
self.book = json.load( open(self.filename, 'rb') )
44+
self.book = json.load( open(self.filename, 'r') )
4545

4646
def close(self):
4747
"""
@@ -56,15 +56,15 @@ def close(self):
5656
a_book = AddressBook()
5757
a_book.load_from_file()
5858

59-
print "the data in the address book is:"
59+
print("the data in the address book is:")
6060
pprint.pprint(a_book.book)
6161

62-
print
63-
print "the first entry is:"
62+
print()
63+
print("the first entry is:")
6464
entry = a_book.book[0]
65-
print entry
66-
print "the first entry's name is:"
67-
print entry['first_name'], entry['last_name']
65+
print(entry)
66+
print("the first entry's name is:")
67+
print(entry['first_name'], entry['last_name'])
6868

6969

7070

Examples/wxpython/address_book/entry_form.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,26 @@ def load_data(self):
8080
load the data into the form from the data dict
8181
"""
8282
data = self._entry
83-
self.fname_text.Value = data.setdefault( u'first_name', "" )
84-
self.lname_text.Value = data.setdefault( u'last_name', "" )
83+
self.fname_text.Value = data.setdefault( 'first_name', "" )
84+
self.lname_text.Value = data.setdefault( 'last_name', "" )
8585

8686
def save_data(self):
8787
"""
8888
save the data from the form to the data dict
8989
"""
9090
data = self._entry
91-
data[u'first_name'] = self.fname_text.Value
92-
data[u'last_name'] = self.lname_text.Value
91+
data['first_name'] = self.fname_text.Value
92+
data['last_name'] = self.lname_text.Value
9393

9494

9595
# I like to have a little test app so it can be run on its own
9696
if __name__ == "__main__":
9797

9898
# a sample entry:
99-
entry = {u'email': u'[email protected]',
100-
u'first_name': u'Chris',
101-
u'last_name': u'Barker',
102-
u'phone': u'123-456-7890'}
99+
entry = {'email': '[email protected]',
100+
'first_name': 'Chris',
101+
'last_name': 'Barker',
102+
'phone': '123-456-7890'}
103103

104104
app = wx.App(False)
105105
f = wx.Frame(None)

Examples/wxpython/address_book/switcher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ def __init__(self, parent, *args, **kwargs):
2828

2929
def onPrev(self, evt=None):
3030
# save the data in the form
31-
print "in onPrev"
31+
print("in onPrev")
3232
self.add_book_frame.previous()
3333
def onNext(self, evt=None):
3434
# restore the form
35-
print "in onNext"
36-
self.add_book_frame.next()
35+
print("in onNext")
36+
next(self.add_book_frame)
3737

3838
class TestFrame(wx.Frame):
3939
"""
4040
simple Frame with jsut enough to text the Switcher
4141
"""
42-
def next(self):
43-
print "next() called in frame"
42+
def __next__(self):
43+
print("next() called in frame")
4444
def previous(self):
45-
print "previous() called in frame"
45+
print("previous() called in frame")
4646

4747
# I like to have a little test app so it can be run on its own
4848
if __name__ == "__main__":

Examples/wxpython/address_book_solution/address_book_app.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ def __init__(self, add_book, *args, **kwargs):
7777

7878
self.SetMenuBar(menuBar)
7979

80-
def next(self):
80+
def __next__(self):
8181
"""
8282
move to the next record in the address book
8383
"""
8484
try:
8585
self.entryPanel.entry = self.add_book.book[self.current_index+1]
8686
self.current_index+=1
8787
except IndexError:
88-
print "At end of records...."
88+
print("At end of records....")
8989
def previous(self):
9090
"""
9191
move to the next record in the address book
@@ -113,24 +113,24 @@ def onOpen(self, evt=None):
113113
if dlg.ShowModal() == wx.ID_OK:
114114
# This returns a Python list of files that were selected.
115115
path = dlg.GetPath()
116-
print "I'd be opening file in onOpen ", path
116+
print("I'd be opening file in onOpen ", path)
117117
self.add_book.load_from_file(filename=path)
118118
else :
119-
print "The file dialog was canceled"
119+
print("The file dialog was canceled")
120120
dlg.Destroy()
121121

122122
def onSave(self, evt=None):
123-
print "in onSave"
123+
print("in onSave")
124124
self.SetStatusText("Saving: %s"%self.add_book.filename)
125125
self.add_book.save_to_file()
126126

127127
def onClose(self, evt=None):
128-
print "close menu selected"
128+
print("close menu selected")
129129
self.add_book.close()
130130

131131
def onExit(self, evt=None):
132-
print "Exit the program here"
133-
print "The event passed to onExit is type ", type(evt),
132+
print("Exit the program here")
133+
print("The event passed to onExit is type ", type(evt), end=' ')
134134
self.Close()
135135

136136

Examples/wxpython/address_book_solution/address_book_data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def new_record(self):
3636
def save_to_file(self, filename=None):
3737
if filename is not None :
3838
self.filename = filename
39-
json.dump(self.book, open(self.filename, 'wb'), indent=4 )
39+
json.dump(self.book, open(self.filename, 'w'), indent=4 )
4040

4141
def load_from_file(self, filename=None):
4242
if filename is not None :
4343
self.filename = filename
44-
self.book = json.load( open(self.filename, 'rb') )
44+
self.book = json.load( open(self.filename, 'r') )
4545

4646
def close(self):
4747
"""
@@ -56,15 +56,15 @@ def close(self):
5656
a_book = AddressBook()
5757
a_book.load_from_file()
5858

59-
print "the data in the address book is:"
59+
print("the data in the address book is:")
6060
pprint.pprint(a_book.book)
6161

62-
print
63-
print "the first entry is:"
62+
print()
63+
print("the first entry is:")
6464
entry = a_book.book[0]
65-
print entry
66-
print "the first entry's name is:"
67-
print entry['first_name'], entry['last_name']
65+
print(entry)
66+
print("the first entry's name is:")
67+
print(entry['first_name'], entry['last_name'])
6868

6969

7070

Examples/wxpython/address_book_solution/entry_form.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,30 +88,30 @@ def load_data(self):
8888
load the data into the form from the data dict
8989
"""
9090
data = self._entry
91-
self.fname_text.Value = data.setdefault( u'first_name', "" )
92-
self.lname_text.Value = data.setdefault( u'last_name', "" )
93-
self.phone_text.Value = data.setdefault( u'phone', "" )
94-
self.email_text.Value = data.setdefault( u'email', "" )
91+
self.fname_text.Value = data.setdefault( 'first_name', "" )
92+
self.lname_text.Value = data.setdefault( 'last_name', "" )
93+
self.phone_text.Value = data.setdefault( 'phone', "" )
94+
self.email_text.Value = data.setdefault( 'email', "" )
9595

9696
def save_data(self):
9797
"""
9898
save the data from the form from the data dict
9999
"""
100100
data = self._entry
101-
data[u'first_name'] = self.fname_text.Value
102-
data[u'last_name'] = self.lname_text.Value
103-
data[u'phone'] = self.phone_text.Value
104-
data[u'email'] = self.email_text.Value
101+
data['first_name'] = self.fname_text.Value
102+
data['last_name'] = self.lname_text.Value
103+
data['phone'] = self.phone_text.Value
104+
data['email'] = self.email_text.Value
105105

106106

107107
# I like to have a little test app so it can be run on its own
108108
if __name__ == "__main__":
109109

110110
# a sample entry:
111-
entry = {u'email': u'[email protected]',
112-
u'first_name': u'Chris',
113-
u'last_name': u'Barker',
114-
u'phone': u'123-456-7890'}
111+
entry = {'email': '[email protected]',
112+
'first_name': 'Chris',
113+
'last_name': 'Barker',
114+
'phone': '123-456-7890'}
115115

116116
app = wx.App(False)
117117
f = wx.Frame(None)

Examples/wxpython/address_book_solution/switcher.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, parent, *args, **kwargs):
1919
2020
:params *args, **kwargs: all the other arguments that a wx.Window takes.
2121
"""
22-
print "in __init__"
22+
print("in __init__")
2323
wx.Panel.__init__(self, parent, *args, **kwargs)
2424

2525
self.add_book_frame = parent
@@ -47,20 +47,20 @@ def __init__(self, parent, *args, **kwargs):
4747

4848
def onPrev(self, evt=None):
4949
# save the data in the form
50-
print "in onPrev"
50+
print("in onPrev")
5151
self.add_book_frame.previous()
5252
def onNext(self, evt=None):
5353
# restore the form
54-
print "in onNext"
55-
self.add_book_frame.next()
54+
print("in onNext")
55+
next(self.add_book_frame)
5656
class TestFrame(wx.Frame):
5757
"""
5858
simple Frame with jsut enough to text the Switcher
5959
"""
60-
def next(self):
61-
print "next() called in frame"
60+
def __next__(self):
61+
print("next() called in frame")
6262
def previous(self):
63-
print "previous() called in frame"
63+
print("previous() called in frame")
6464

6565
# I like to have a little test app so it can be run on its own
6666
if __name__ == "__main__":

Examples/wxpython/basic_app_2.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class AppLogic(object):
2121
"""
2222
def file_open(self, filename="default_name"):
2323
"""This method opens a file"""
24-
print "Open a file: "
25-
print "I'd be opening file: %s now"%filename
24+
print("Open a file: ")
25+
print("I'd be opening file: %s now"%filename)
2626

2727
def file_close(self):
2828
"""This method closes a file"""
29-
print "Close a file: "
30-
print "I'd be closing a file now"
29+
print("Close a file: ")
30+
print("I'd be closing a file now")
3131

3232

3333
class TestFrame(wx.Frame):
@@ -39,7 +39,7 @@ def __init__(self, app_logic, *args, **kwargs):
3939

4040
# Add a panel so it looks the correct on all platforms
4141
self.panel = wx.Panel(self, wx.ID_ANY)
42-
42+
4343

4444
# Build up the menu bar:
4545
menuBar = wx.MenuBar()
@@ -62,17 +62,17 @@ def __init__(self, app_logic, *args, **kwargs):
6262
self.SetMenuBar(menuBar)
6363

6464
def onOpen(self, evt=None):
65-
print "open menu selected"
66-
print evt
65+
print("open menu selected")
66+
print(evt)
6767
self.app_logic.file_open()
6868

6969
def onClose(self, evt=None):
70-
print "close menu selected"
70+
print("close menu selected")
7171
self.app_logic.file_close()
7272

7373
def onExit(self, evt=None):
74-
print "Exit the program here"
75-
print "The event passed to onExit is type ", type(evt),
74+
print("Exit the program here")
75+
print("The event passed to onExit is type ", type(evt),)
7676
self.Close()
7777

7878

Examples/wxpython/basic_app_3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, app_logic, *args, **kwargs):
6262
saveasMenuItem = fileMenu.Append(wx.ID_ANY, "&Save As", "Create a new file")
6363
self.Bind(wx.EVT_MENU, self.onSaveAs, saveasMenuItem)
6464

65-
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file" )
65+
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file")
6666
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
6767

6868
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file")

0 commit comments

Comments
 (0)