SunQuest
 
       Python
  Home arrow Python arrow Page 3 - Alternative Frames in wxPython
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Alternative Frames in wxPython
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2005-08-29

    Table of Contents:
  • Alternative Frames in wxPython
  • wxDialog
  • wxWizard
  • Multiple Document Interface

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Alternative Frames in wxPython - wxWizard


    (Page 3 of 4 )

    We've all seen wizards in all sorts of applications. They exist to make tasks easy. They are found in installers, graphics programs and even wxPython. Using the wizard module, we can create wizards to use in our applications, making them even more user-friendly. Best of all, these wizards are pretty easy to create. Here's a very simple dummy wizard:

    from wxPython.wx import *

    # The wizard-related classes are here:

    from wxPython.wizard import *

    application = wxPySimpleApp()

    # Create a wizard with the title "A Wizard"

    wizard = wxWizard ( None, -1, 'A Wizard' )

    # Create three pages for the wizard

    # This is very simple

    wizardPage1 = wxWizardPageSimple ( wizard )

    wizardPage2 = wxWizardPageSimple ( wizard )

    wizardPage3 = wxWizardPageSimple ( wizard )

    # Add a label to each page

    label1 = wxStaticText ( wizardPage1, -1, 'This is the first page.' )

    label2 = wxStaticText ( wizardPage2, -1, 'This is the second page.' )

    label3 = wxStaticText ( wizardPage3, -1, 'This is the third and final page.' )

    # Link the pages together

    # 1 to 2 and 2 to 3

    wxWizardPageSimple_Chain ( wizardPage1, wizardPage2 )

    wxWizardPageSimple_Chain ( wizardPage2, wizardPage3 )

    # Run the wizard and display a message if it was completed successfully

    # Otherwise, yell at the user

    if wizard.RunWizard ( wizardPage1 ):

       dialog = wxMessageDialog ( None, 'Wizard finished!', 'Finished', style = wxOK )

       dialog.ShowModal()

       dialog.Destroy()

    else:

       dialog = wxMessageDialog ( None, 'Grr!', 'Not Finished', style = wxOK )

       dialog.ShowModal()

       dialog.Destroy()

    # Destroy the wizard

    wizard.Destroy()

    There are more advanced and flexible methods for creating wizards, too. Let's suppose we are creating an installer with two installation modes: minimal and full. Based on the user's selection, we want to go to different sections of the wizard. This is completely possible, but it is done a little differently from the way we did it above:

    from wxPython.wx import *

    # Import the wizard-related data

    from wxPython.wizard import *

    # Create the wizard page that allows the use to select an installation type

    # We wills subclass wxPyWizardPage here

    class TypePage ( wxPyWizardPage ):

       def __init__ ( self, parent ):

          # Call __init__

          wxPyWizardPage.__init__ ( self, parent )

          # Specify None for the next and previous pages

          self.next = None

          self.previous = None

          # Add a wxRadioBox that displays the two installation options

          self.box = wxRadioBox ( self, -1, 'Instalation Method', choices = [ 'Minimal', 'Full' ] )

       def GetNext ( self ):

          # Return a value based on the radio buttons elected

          if self.box.GetSelection() == 0:

             return minimal

          else:

             return full

       def GetPrev ( self ):

          return self.previous

    application = wxPySimpleApp()

    # Create the wizard

    wizard = wxWizard ( None, -1, 'Installer' )

    # Create the installation type page

    type = TypePage ( wizard )

    # Create a page for the minimal mode

    minimal = wxWizardPageSimple ( wizard )

    minimalText = wxStaticText ( minimal, -1, 'Poof. Your application has been installed minimally.' )

    # Create a page for the full mode

    full = wxWizardPageSimple ( wizard )

    fullText = wxStaticText ( full, -1, 'Bang. Your application has been fully installed.' )

    # Create an additional page

    register = wxWizardPageSimple ( wizard )

    registerText = wxStaticText ( register, -1, 'Please register your product online,nor we will keep nagging you.' )

    # Link the pages that have fixed links ( minimal and full )

    minimal.SetNext ( register )

    full.SetNext ( register )

    # Run the wizard

    wizard.RunWizard ( type )

    # Destroy the wizard

    wizard.Destroy()

    If you feel inclined to do so, you can easily add an image to your wizard by creating it like this, where “wizard.PNG” is the name of the image:

    wizard = wxWizard ( None, -1, 'My Wizard', wxBitmap ( 'wizard.PNG' )

    More Python Articles
    More By Peyton McCullough


       · Hey, all. This article just presents some new canvases to work with. Before you read...
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway