@@ -71,8 +71,6 @@ \section{Introduction}
71
71
72
72
\begin {frame }[fragile]{Python Options}
73
73
74
-
75
-
76
74
{\Large Multiple GUI frameworks available:}
77
75
78
76
\begin {itemize }
@@ -87,6 +85,7 @@ \section{Introduction}
87
85
88
86
\end {frame }
89
87
88
+
90
89
\section {wxPython }
91
90
92
91
\begin {frame }[fragile]{wxPython}
@@ -203,6 +202,56 @@ \section{wxPython}
203
202
204
203
\end {frame }
205
204
205
+ % -------------------------------
206
+ \begin {frame }[fragile]{Pythonic code:}
207
+
208
+
209
+ \vfill
210
+ {\Large Over the years, wxPython has grown a number of things to make it more `` pythonic'' -- hide some of that C++ legacy}
211
+
212
+ \vfill
213
+ {\Large Properties:}
214
+
215
+ {\large The C++ classes are full of getters and setters:}
216
+ \begin {verbatim }
217
+ wxTextCtrl::GetValue
218
+ wxTextCtrl::GetValue
219
+ \end {verbatim }
220
+
221
+ {\large These methods have been translated into properties for Python}
222
+ \begin {verbatim }
223
+ MyTextCtrl.Value = some_string
224
+ another_string = wxTextCtrl.Value
225
+ \end {verbatim }
226
+
227
+ \vfill
228
+ (The Get/Set versions are still there, but it's klunkier code)
229
+ \end {frame }
230
+
231
+ % -------------------------------
232
+ \begin {frame }[fragile]{Pythonic code:}
233
+
234
+
235
+ \vfill
236
+ {\Large Other Python options: some specific wx types can be accessed with standard python types:}
237
+
238
+ \vfill
239
+ {\large \verb `wxPoint ` --- \verb `(x,y) ` ( tuple ) }
240
+
241
+ \vfill
242
+ {\large \verb `wx.List ` --- \verb `[1,2,3] ` (python list) }
243
+
244
+ \vfill
245
+ {\large \verb `wxSize ` --- \verb `(w,h) ` (tuple) }
246
+
247
+ \vfill
248
+ {\large ....... }
249
+
250
+
251
+ \vfill
252
+ {\Large Using these makes your code cleaner and more pythonic}
253
+
254
+ \end {frame }
206
255
207
256
\section {Basic Structure }
208
257
@@ -367,6 +416,7 @@ \section{Basic Structure}
367
416
368
417
\end {frame }
369
418
419
+ \section {controls }
370
420
371
421
% -------------------------------
372
422
\begin {frame }[fragile]{Menus}
@@ -610,13 +660,13 @@ \section{Basic Structure}
610
660
{\Large The alternative is `` Sizers'' }
611
661
612
662
\vfill
613
- {\large \verb `wx.Sizer ` is wx's system for automatically determining the size an location of controls}
663
+ {\large \verb `wx.Sizer ` is wx's system for automatically determining the size and location of controls}
614
664
615
665
\vfill
616
- {\large Instead of thinking in terms of what size an position a given control should be, you think in terms of how they relate to each other:}
666
+ {\large Instead of thinking in terms of what size and position a given control should be, you think in terms of how they relate to each other:}
617
667
618
668
\vfill
619
- {\large `` I want a column of buttons all the same size along the left edge of the Panel'' }
669
+ {\large \emph { `` I want a column of buttons all the same size along the left edge of the Panel'' } }
620
670
621
671
\vfill
622
672
{\large Sizers capture that logic and compute the sizes for you}
@@ -735,7 +785,53 @@ \section{Basic Structure}
735
785
736
786
\end {frame }
737
787
788
+
789
+ % -------------------------------
790
+ \begin {frame }[fragile]{Accessing inputs}
791
+
792
+ {\Large Much of the point of a GUI is to collect data from the user.}
793
+
794
+ \vfill
795
+ {\large So you need to be able to access what s/he has input}
796
+
797
+ \begin {verbatim }
798
+ ## add a text control:
799
+ self.textControl = wx.TextCtrl(self)
800
+
801
+ def onGetData(self, evt=None):
802
+ print "get data button pressed"
803
+ contents = self.textControl.Value
804
+ print "the contents are:", contents
805
+ \end {verbatim }
806
+
807
+ {\large Most controls have a \verb `.Value ` property}
808
+
809
+ \end {frame }
810
+
738
811
% -------------------------------
812
+ \begin {frame }[fragile]{Setting Values}
813
+
814
+ {\Large You also want to display data...}
815
+
816
+ \vfill
817
+ {\large So you need to be able to set the values, too:}
818
+
819
+ \begin {verbatim }
820
+ ## and another text control:
821
+ self.outTextControl = wx.TextCtrl(self, style=wx.TE_READONLY)
822
+
823
+ def onGetData(self, evt=None):
824
+ self.outTextControl.Value = self.inTextControl.Value
825
+
826
+ \end {verbatim }
827
+
828
+ {\large You can set the \verb `.Value ` property too...}
829
+
830
+ \vfill
831
+ example: \verb `code\basic_app8.py `
832
+
833
+ \end {frame }
834
+
739
835
740
836
% -------------------------------
741
837
\begin {frame }[fragile]{Long Running Tasks}
@@ -761,6 +857,8 @@ \section{Basic Structure}
761
857
762
858
\end {frame }
763
859
860
+ \section {Miscellaneous }
861
+
764
862
% -------------------------------
765
863
\begin {frame }[fragile]{CallAfter}
766
864
@@ -810,6 +908,20 @@ \section{Basic Structure}
810
908
\vfill
811
909
{\Large Example: Cameo Chemicals}
812
910
911
+ \vfill
912
+ (PyCon 2009: Browser Interface, Local Server Application)
913
+ \end {frame }
914
+
915
+
916
+ % -------------------------------
917
+ \begin {frame }[fragile]{LAB}
918
+
919
+ \vfill
920
+ {\Large Make a very simple address book app:}
921
+ \vfill
922
+
923
+ \verb `code\address_book\ `
924
+
813
925
\end {frame }
814
926
815
927
0 commit comments