@@ -295,7 +295,7 @@ This is where menu bars, etc. are placed, and often the core GUI logic of the ap
295295 wx.Frame.__init__ (self , * args, ** kwargs)
296296
297297
298- demo: ``Examples\ wxpython\ basic_app_1.py ``
298+ demo: ``Examples/ wxpython/ basic_app_1.py ``
299299
300300
301301Controls
@@ -326,7 +326,7 @@ A ``wx.Frame`` has a menu bar you can add items to:
326326 self .SetMenuBar(menuBar)
327327
328328
329- demo: ``Examples\ wxpython\ basic_app_2.py ``
329+ demo: ``Examples/ wxpython/ basic_app_2.py ``
330330
331331
332332Event Handlers
@@ -347,7 +347,7 @@ The second parameter is the ``wx.Event`` object that initiated the call -- it ho
347347I like to give the event parameter a default None, so the handler can be called from other parts of the code as well.
348348
349349
350- demo: ``Examples\ wxpython\ basic_app_2.py ``
350+ demo: ``Examples/ wxpython/ basic_app_2.py ``
351351
352352
353353Common Dialogs
@@ -441,7 +441,7 @@ Mostly the same as wx.Window, and other controls....
441441
442442
443443
444- code: ``Examples\ wxpython\ basic_app_4.py ``
444+ code: ``Examples/ wxpython/ basic_app_4.py ``
445445
446446
447447wx.Panel
@@ -476,16 +476,16 @@ And use it in the Frame:
476476 self .buttonPanel = ButtonPanel(self )
477477
478478
479- code: ``Examples\ wxpython\ basic_app_5.py ``
479+ code: ``Examples/ wxpython/ basic_app_5.py ``
480480
481481
482482Control Layout
483483--------------
484484
485485With more than one control, you need to figure out how to place them
486- and how big to make them
486+ and how big to make them.
487487
488- You may have noticed that ``wx.Window `` takes ``pos `` and ``size `` parameters
488+ You may have noticed that ``wx.Window `` takes ``pos `` and ``size `` parameters.
489489
490490You may have also noticed that I didn't use them.
491491
@@ -539,12 +539,12 @@ Instead of thinking in terms of what size and position a given control should be
539539
540540Sizers capture that logic and compute the sizes and locations for you.
541541
542- They will re-size things for you when anything changes -- adding, removing, changing labels, re-sizing the Window, etc...
543-
542+ They will re-size things for you when anything changes:
543+ - adding, removing, changing labels
544+ - re-sizing the Window, etc...
544545
545546.. nextslide ::
546547
547-
548548Sizers take a while to wrap your brain around...
549549
550550But it's worth the learning curve.
@@ -553,22 +553,19 @@ Nice discussion here:
553553
554554http://wiki.wxpython.org/UsingSizers
555555
556-
557556I have the graphic posted on the wall by my desk...
558557
559558
560-
561559Sizer Example
562560-------------
563561
564562The Basic ``BoxSizer ``:
565563
566564- Lays out a row or column of controls...
567565
566+ .. code-block :: python
568567
569- ..code-block:: python
570-
571- Sizer.Add( window, proportion, flag, border )
568+ Sizer.Add(window, proportion, flag, border)
572569 # # do the layout
573570 S = wx.BoxSizer(wx.VERTICAL )
574571
@@ -578,7 +575,7 @@ The Basic ``BoxSizer``:
578575 self .SetSizerAndFit(S)
579576
580577
581- code: ``Examples\ wxpython\ basic_app_6.py ``
578+ code: ``Examples/ wxpython/ basic_app_6.py ``
582579
583580
584581Nested Sizers
@@ -623,7 +620,7 @@ The Widget Inspection Tool (WIT) is very handy:
623620 (you can also bring it up from a menu event, or...)
624621
625622
626- code: ``Examples\ wxpython\ basic_app_7.py ``
623+ code: ``Examples/ wxpython/ basic_app_7.py ``
627624
628625
629626
@@ -638,7 +635,7 @@ Sizers for laying out stuff in grids...
638635
639636``wx.GridBagSizer ``
640637
641- (you can do it all with a GridBagSizer)
638+ (you can do it all with a `` GridBagSizer `` )
642639
643640See the docs for info.
644641
@@ -649,46 +646,40 @@ Hierarchies...
649646wxPython has multiple independent hierarchies ...
650647
651648
652- The nested parent-child relationship:
649+ ** The nested parent-child relationship: **
653650
654651* every ``wx.Window `` has a parent
655652* every ``wx.Window `` has zero or more children
656653
657-
658- The class Hierarchy
654+ **The class Hierarchy **
659655
660656* sub classes of ``wx.Window ``
661657* classes with instances as attributes
662658
663-
664- The Layout Hierarchy
659+ **The Layout Hierarchy **
665660
666661* Sizers within Sizers...
667662* Arbitrarily deep.
668663
669-
670-
671- Each of these takes care of different concerns: confusing but powerful
664+ Each of these takes care of different concerns: confusing but powerful.
672665
673666
674667Accessing inputs
675668----------------
676669
677670Much of the point of a GUI is to collect data from the user.
678671
672+ So you need to be able to access what s/he has input.
679673
680- So you need to be able to access what s/he has input
681-
682- ..code-block:: python
674+ .. code-block :: python
683675
684676 # # add a text control:
685677 self .textControl = wx.TextCtrl(self )
686678
687679 def onGetData (self , evt = None ):
688- print "get data button pressed"
680+ print ( " get data button pressed" )
689681 contents = self .textControl.Value
690- print "the contents are:", contents
691-
682+ print (" the contents are:" , contents)
692683
693684 Most controls have a ``.Value `` property
694685
@@ -713,35 +704,31 @@ So you need to be able to set the values, too:
713704 You can set the ``.Value `` property too...
714705
715706
716- example: ``Examples\ wxpython\ basic_app8.py ``
707+ example: ``Examples/ wxpython/ basic_app8.py ``
717708
718709
719710Code-generated GUIs...
720711----------------------
721712
722713You shouldn't write the same repetitive code for a GUI...
723714
724-
725715You may need to build a GUI to match data at run time.
726716
727-
728717Lots of ways to do that with wxPython -- Sizers help a lot.
729718
730-
731719Try to do it whenever you find yourself writing repetitive code...
732720
733-
734721The key is how to do the event Binding:
735722
736- ..code-block:: python
723+ .. code-block :: python
737724
738725 def OnButton (self , evt ):
739726 label = evt.GetEventObject().GetLabel()
740727
741728 do_somethign_with_label(label)
742729
743730
744- example: ``Examples\ wxpython/CalculatorDemo.py ``
731+ example: ``Examples/ wxpython/CalculatorDemo.py ``
745732
746733
747734.. nextslide ::
@@ -760,7 +747,7 @@ The "lambda trick"
760747 ... .
761748
762749 def OnButton (self , Event , name ):
763- print " In OnButton:" , name
750+ print ( " In OnButton:" , name)
764751
765752
766753 http://wiki.wxpython.org/Passing%20Arguments%20to%20Callbacks
@@ -769,24 +756,24 @@ http://wiki.wxpython.org/Passing%20Arguments%20to%20Callbacks
769756Miscellaneous
770757=============
771758
759+ .. rst-class :: medium
760+
761+ Assorted handy features....
762+
763+
772764Long Running Tasks
773765------------------
774766
775- The UI is locked up while an event is being handled
776-
767+ The UI is locked up while an event is being handled.
777768
778769So you want all event handlers to run fast.
779770
780-
781771But what if there is significant work to do?
782772
783-
784773Enter: threading and multi-processing
785774
786-
787775But: wxPython is not thread-safe: almost all wx methods must be called from within the same thread.
788776
789-
790777Thread-safe operations: Creating and Posting Events
791778
792779``wx.CallAfter ``
@@ -796,7 +783,6 @@ Easiest way to communicate with threads:
796783
797784``wx.CallAfter ``
798785
799-
800786Puts an event on the event stack, calls the designated function or method when the stack is cleared:
801787
802788.. code-block :: python
@@ -817,22 +803,16 @@ BILS
817803
818804Browser Interface, Local Server
819805
820-
821806Web app: Server runs on local machine
822807
823-
824808Browser is the interface -- but all running local
825809
826-
827810Can wrap the Browser window in a desktop app: Chrome Embedded Framework, wxWebkit, etc.
828811
829-
830812Good way to get both a web app and desktop app with one codebase
831813
832-
833814Example: Cameo Chemicals
834815
835-
836816(PyCon 2009: Browser Interface, Local Server Application)
837817
838818
@@ -842,14 +822,12 @@ LAB
842822Make a very simple address book app:
843823
8448241. Really basic data model is in ``address_book_data.py ``
845- 2. Finish the form to edit an entry -- subclass of a ``wx.Panel `` (``entry_form.py ``)
825+ 2. Finish the form to edit an entry -- subclass of a ``wx.Panel ``
826+ (``entry_form.py ``)
8468273. The form goes on a ``wx.Frame `` (``address_book_app.py ``)
847- add a way to switch between entries (``switcher.py ``)
848- 4. Add a "new record" button
849- 5. Add file--save and file--open menus to the frame
850- 6. Add some validation, better layout, etc....
851-
852-
853- ``Examples\wxpython\address_book\ ``
854-
828+ 4. Add a way to switch between entries (``switcher.py ``)
829+ 5. Add a "new record" button
830+ 6. Add file-save and file-open menus to the frame
831+ 7. Add some validation, better layout, etc....
855832
833+ ``Examples/wxpython/address_book/ ``
0 commit comments