You are previewing wxPython 2.8 Application Development Cookbook.
O'Reilly logo
wxPython 2.8 Application Development Cookbook

Book Description

Over 80 practical recipes for developing feature-rich applications using wxPython

  • Develop flexible applications in wxPython.

  • Create interface translatable applications that will run on Windows, Macintosh OSX, Linux, and other UNIX like environments.

  • Learn basic and advanced user interface controls.

  • Packed with practical, hands-on cookbook recipes and plenty of example code, illustrating the techniques to develop feature rich applications using wxPython.

In Detail

In today’s world of desktop applications there is a great amount of incentive to be able to develop applications that can run in more than one environment. Currently there are a handful of options available for cross platform frameworks to develop desktop applications in Python. wxPython is one such cross- platform GUI toolkit for the Python programming language. It allows Python programmers to create programs with a complete, highly functional graphical user interface, simply and easily. wxPython code style has changed quite a bit over the years, and gotten much more Pythonic. The examples you will find in this book are right up to date and reflect this change in style.

This cookbook provides you with the latest recipes to quickly create robust, reliable, and reusable wxPython applications. These recipes will guide you from writing simple, basic wxPython scripts all the way through complex concepts, and also feature various design approaches and techniques in wxPython.

The book starts off by covering a variety of topics from the most basic requirements of a wxPython application to some of the more in depth details of the inner workings of the framework laying the foundation for any wxPython application. It then explains event handling, basic and advanced user interface controls, designing and layout, creating dialogs, components and extending functionality, and so on. We conclude by learning how to build and manage applications for distribution. For each of the recipes, there is an introductory example, then more advanced examples, and plenty of example code to develop and manage user-friendly applications. For more experienced developers, most recipes also include additional discussion of the solution, allowing you to further customize and enhance the component.

Quickly create robust, reliable, and reusable wxPython applications

Table of Contents

  1. wxPython 2.8 Application Development Cookbook
    1. wxPython 2.8 Application Development Cookbook
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. Getting Started with wxPython
      1. Introduction
      2. The application object
        1. How to do it...
        2. How it works...
        3. There's more...
      3. The main frame
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Understanding the window hierarchy
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Referencing controls
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Using Bitmaps
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      7. Adding icons to Windows
        1. How to do it...
        2. How it works...
        3. See also
      8. Utilizing Stock IDs
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      9. Accessing the clipboard
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      10. Supporting drag and drop
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      11. Two-stage widget creation
        1. How to do it...
        2. How it works...
        3. See also
      12. Understanding inheritance limitations
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
    8. 2. Responding to Events
      1. Introduction
      2. Handling events
        1. How to do it...
        2. How it works...
        3. See also
      3. Understanding event propagation
        1. How to do it...
        2. How it works...
        3. See also
      4. Handling Key events
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      5. Using UpdateUI events
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Playing with the mouse
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      7. Creating custom event classes
        1. How to do it...
        2. How it works...
        3. See also
      8. Managing event handlers with EventStack
        1. How to do it...
        2. How it works...
        3. See also
      9. Validating input with validators
        1. How to do it...
        2. How it works...
        3. See also
      10. Handling Apple events
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
    9. 3. Basic Building Blocks of a User Interface
      1. Introduction
      2. Creating Stock Buttons
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      3. Buttons, buttons, and more buttons
        1. How to do it...
        2. How it works...
          1. ToggleButton
          2. BitmapButton
          3. PlateButton
          4. GradientButton
        3. There's more...
          1. GenericButtons
          2. AquaButton
        4. See also
      4. Offering options with CheckBoxes
        1. How to do it...
        2. How it works...
        3. See also
      5. Using the TextCtrl
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Providing choices with the Choice control
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Adding Menus and MenuBars
        1. How to do it...
        2. How it works...
        3. There's more...
          1. SubMenus
          2. Customizing MenuItems
        4. See also
      8. Working with ToolBars
        1. How to do it...
        2. How it works...
        3. There's more...
          1. ToolBar styles
          2. Additional types of tools
          3. Events
        4. See also
      9. How to use PopupMenus
        1. How to do it...
        2. How it works...
        3. See also
      10. Grouping controls with a StaticBox
        1. How to do it...
        2. How it works...
        3. See also
    10. 4. Advanced Building Blocks of a User Interface
      1. Introduction
      2. Listing data with a ListCtrl
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Virtual Mode
        4. See also
      3. Browsing files with the CustomTreeCtrl
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Creating a VListBox
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      5. StyledTextCtrl using lexers
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Working with tray icons
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      7. Adding tabs to a Notebook
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Styles
          2. Events
        4. See also
      8. Using the FlatNotebook
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Style flags
        4. See also
      9. Scrolling with a ScrolledPanel
        1. How to do it...
        2. How it works...
      10. Simplifying the FoldPanelBar
        1. How to do it...
        2. How it works...
        3. There's more...
    11. 5. Providing Information and Alerting Users
      1. Introduction
      2. Showing a MessageBox
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Icons
          2. Buttons
      3. Providing help with ToolTips
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Using SuperToolTips
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Styles
          2. Additional customization
        4. See also
      5. Displaying a BalloonTip
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Creating a custom SplashScreen
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Showing task progress with the Progress dialog
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Message parameter
          2. Style flags
      8. Creating an AboutBox
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
    12. 6. Retrieving Information from Users
      1. Introduction
      2. Selecting files with a FileDialog
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Default paths
          2. Style flags
        4. See also
      3. Searching text with a FindReplaceDialog
        1. How to do it...
        2. How it works...
        3. There's more...
          1. FindReplaceDialog style flags
          2. FindReplaceData flags
        4. See also
      4. Getting images with ImageDialog
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      5. Using the Print dialogs
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Printout
          2. Bug notice
        4. See also
    13. 7. Window Layout and Design
      1. Introduction
      2. Using a BoxSizer
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Spacers
          2. AddMany
        4. See also
      3. Understanding proportions, flags, and borders
        1. Getting Started
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Alignment flags
          2. Border flags
          3. Behavior flags
        5. See also
      4. Laying out controls with the GridBagSizer
        1. How to do it...
        2. How it works...
        3. See also
      5. Standard dialog button layout
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Using XML resources
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Loading other types of resources
          2. Specifying standard IDs
        4. See also
      7. Making a custom resource handler
        1. Getting Started
        2. How to do it...
        3. How it works...
        4. See also
      8. Using the AuiFrameManager
        1. How to do it...
        2. How it works...
        3. There's more...
    14. 8. Drawing to the Screen
      1. Introduction
      2. Screen drawing
        1. How to do it...
        2. How it works...
        3. See also
      3. Drawing shapes
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Utilizing SystemSettings
        1. How to do it...
        2. How it works...
        3. There's more
        4. See also
      5. Using a GraphicsContext
        1. How to do it...
        2. How it works...
        3. See also
      6. Drawing with RendererNative
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Drawing Methods
          2. Control Flags
        4. See also
      7. Reducing flicker in drawing routines
        1. How to do it...
        2. How it works...
        3. See also
    15. 9. Design Approaches and Techniques
      1. Introduction
      2. Creating Singletons
        1. How to do it...
        2. How it works...
      3. Implementing an observer pattern
        1. How to do it...
        2. How it works...
        3. See also
      4. Strategy pattern
        1. How to do it...
        2. How it works...
        3. See also
      5. Model View Controller
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Using mixin classes
        1. How to do it...
        2. How it works...
        3. There's more
          1. ListCtrl mixins
          2. TreeCtrl mixins
      7. Using decorators
        1. How to do it...
        2. How it works...
        3. See also
    16. 10. Creating Components and Extending Functionality
      1. Introduction
      2. Customizing the ArtProvider
        1. How to do it...
        2. How it works...
        3. See also
      3. Adding controls to a StatusBar
        1. How to do it...
        2. How it works...
        3. See also
      4. Making a tool window
        1. How to do it...
        2. How it works...
        3. See also
      5. Creating a SearchBar
        1. How to do it...
        2. How it works...
        3. See also
      6. Working with ListCtrl mixins
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      7. StyledTextCtrl custom highlighting
        1. How to do it...
        2. How it works...
        3. See also
      8. Creating a custom control
        1. How to do it...
        2. How it works...
        3. See also
    17. 11. Using Threads and Timers to Create Responsive Interfaces
      1. Introduction
      2. Non-Blocking GUI
        1. How to do it...
        2. How it works...
        3. See also
      3. Understanding thread safety
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Threading tools
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      5. Using Timers
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Capturing output
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
    18. 12. Building and Managing Applications for Distribution
      1. Introduction
      2. Working with StandardPaths
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      3. Persisting the state of the UI
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Using the SingleInstanceChecker
        1. How to do it...
        2. How it works...
        3. See also
      5. Exception handling
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Optimizing for OS X
        1. How to do it...
        2. How it works...
        3. There's more...
          1. wx.App Macintosh specific methods
          2. wx.MenuBar
        4. See also
      7. Supporting internationalization
        1. How to do it...
        2. How it works...
        3. There's more...
      8. Distributing an application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Py2Exe dependencies
          2. Installers