Home arrow Python arrow Page 4 - Alternative Frames in wxPython

Multiple Document Interface - Python

I'm sure you know all about wxPython's primary frame, wxFrame. It is the basis for most of your windows and will most likely continue to be. Of course, though, wxPython offers other things to put controls on. I'm sure you're getting bored of attaching your controls to slight variations of the same exact thing. In this article, we'll explore other frames offered by wxPython, examining what they are for, how they are used and how to change their appearance.

  1. Alternative Frames in wxPython
  2. wxDialog
  3. wxWizard
  4. Multiple Document Interface
By: Peyton McCullough
Rating: starstarstarstarstar / 9
August 29, 2005

print this article



Microsoft's Multiple Document Interface, or MDI, allows a parent window to house multiple child windows. The wxPython library supports the Multiple Document Interface, and it is simple to include it in your applications:

from wxPython.wx import *

# Subclass wxMDIParentFrame

class Parent ( wxMDIParentFrame ):

   def __init__ ( self ):

      # Call __init__ and make the window big

      wxMDIParentFrame.__init__ ( self, None, -1, "Multiple Document Interface Test", size = ( 500, 500 ) )

      # Create a menu that allows us to open new windows

      windowMenu = wxMenu()

      windowMenu.Append ( 1, 'Open New' )

      # Create a menu bar and add the menu

      menuBar = wxMenuBar()

      menuBar.Append ( windowMenu, 'Options' )

      self.SetMenuBar ( menuBar )

      # Catch a menu click

      EVT_MENU ( self, 1, self.openNew )

      self.Show ( True )

   # This method will add a window

   def openNew ( self, event ):

      # Create a child window

      child = wxMDIChildFrame ( self, -1, 'MDI Child' )

      # Give the child a panel

      child.panel = wxPanel ( child, -1 )

      child.panel.SetSize ( child.GetClientSize() )

      # Add a label

      child.label = wxStaticText ( child, -1, 'I am only a child.' )

      child.Show ( True )

application = wxPySimpleApp()



Although the idea sounds complicated at first, wxPython makes it all extremely easy, requiring only a handful of code to create something basic like we did. Notice, too, that a “Window” menu is added to our application, giving us organization and navigation options.

The Multiple Document Interface is useful in some applications. Each window has the potential to be very different from the next window, too. It's all up to your creativity.


The wxPython library offers more frames than just wxFrame. These frames are geared toward specific things, such as modal dialogs, modeless dialogs, wizards and organizing child windows within a large parent window. They enable you to extend your application's capabilities with little effort, and, at the same time, give you a variety of complex options. They can be excellent additions to your applications, benefitting the end user and, in turn, you –- the developer.

>>> More Python Articles          >>> More By Peyton McCullough

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates


Dev Shed Tutorial Topics: