Skip to content

Commit b1ecfec

Browse files
presentation, examples and excercises for decorators
1 parent ac3bf8c commit b1ecfec

21 files changed

+1831
-31
lines changed

week-08.5/code/basic_app_2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, app_logic, *args, **kwargs):
6363

6464
def onOpen(self, evt=None):
6565
print "open menu selected"
66+
print evt
6667
self.app_logic.file_open()
6768

6869
def onClose(self, evt=None):

week-08.5/code/basic_app_4.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ def __init__(self, app_logic, *args, **kwargs):
7777
## add just a single button:
7878
self.theButton = wx.Button(self, label="Push Me")
7979
self.theButton.Bind(wx.EVT_BUTTON, self.onButton)
80-
self.theButton.Bind(wx.EVT_LEFT_DOWN, self.onButton)
80+
self.theButton.Bind(wx.EVT_RIGHT_DOWN, self.onRight)
8181

8282

8383
def onButton(self, evt=None):
8484
print "You pushed the button!"
8585
evt.Skip()
86+
def onRight(self, evt=None):
87+
print "right click!"
88+
evt.Skip()
8689

8790
def onClose(self, evt=None):
8891
print "close menu selected"

week-08.5/code/basic_app_5.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ def __init__(self, app_logic, *args, **kwargs):
8989

9090
self.SetMenuBar(menuBar)
9191

92-
## add just a single button:
93-
self.theButton = wx.Button(self, label="Push Me")
94-
self.theButton.Bind(wx.EVT_BUTTON, self.onButton)
95-
96-
def onButton(self, evt=None):
97-
print "You pushed the button!"
98-
9992
def onClose(self, evt=None):
10093
print "close menu selected"
10194
self.file_close()

week-08.5/code/basic_app_6.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def __init__(self, *args, **kwargs):
6060
#S = wx.BoxSizer(wx.VERTICAL)
6161
S = wx.BoxSizer(wx.HORIZONTAL)
6262

63-
S.Add(theButton1, 1, wx.GROW | wx.ALL, 4)
64-
S.Add(theButton2, 2, wx.GROW | wx.ALL, 4)
63+
S.Add(theButton1, 0, wx.GROW | wx.ALL, 4)
64+
S.Add(theButton2, 0, wx.GROW | wx.ALL, 4)
6565

6666
self.SetSizerAndFit(S)
6767

week-08.5/code/basic_app_7.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ def __init__(self, *args, **kwargs):
5757
## do the layout
5858
buttonSizer = wx.BoxSizer(wx.VERTICAL)
5959

60+
buttonSizer.Add((1,1), 1) # stretchable space
6061
buttonSizer.Add(theButton1, 0, wx.GROW | wx.ALL, 4)
6162
buttonSizer.Add(theButton2, 0, wx.GROW | wx.ALL, 4)
63+
buttonSizer.Add((1,1), 3) # stretchable space
6264

6365
## need another sizer to get the horizonal placement right:
6466
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
6567
mainSizer.Add((1,1), 1) # stretchable space
66-
mainSizer.Add(buttonSizer, 0, wx.ALIGN_LEFT) # the sizer with the buttons in it
68+
mainSizer.Add(buttonSizer, 0, wx.GROW) # the sizer with the buttons in it
6769
mainSizer.Add((1,1), 1) # stretchable space
6870

6971
self.SetSizer(mainSizer)

week-08.5/code/basic_app_8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def onGetData(self, evt=None):
9494
contents = self.inTextControl.Value
9595
print "the contents are:", contents
9696

97-
self.outTextControl.Value = self.inTextControl.Value
97+
self.outTextControl.Value = self.inTextControl.Value.upper()
9898

9999

100100
class TestFrame(wx.Frame):
2 Bytes
Binary file not shown.

week-08.5/presentation-wxpython.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ \section{controls}
711711
\begin{frame}[fragile]{Nested Sizers}
712712

713713
{\Large How do I get them centered both ways?}\\
714-
{\large -- Nest a vertical inside a horizonal}\\
714+
{\large -- Nest a vertical sizer inside a horizonal one}\\
715715
{\large -- And add stretchable spacers...}
716716

717717
\vfill
@@ -995,7 +995,7 @@ \section{Miscellaneous}
995995
\begin{enumerate}
996996
\item Really basic data model is in \verb`address_book_data.py`
997997
\item Finish the form to edit an entry -- subclass of a \verb`wx.Panel` (\verb`entry_form.py`)
998-
\item The form goes on a \verb`wx.Frame` (\verb`address_book_app.py`) --
998+
\item The form goes on a \verb`wx.Frame` (\verb`address_book_app.py`) \\
999999
add a way to switch between entries (\verb`switcher.py`)
10001000
\item Add a ``new record'' button
10011001
\item Add file--save and file--open menus to the frame

0 commit comments

Comments
 (0)