Home arrow Python arrow Organization in wxPython

Organization in wxPython

While absolute positioning of controls may work in some odd cases, absolute positioning isn't convenient or pretty. This article will explain methods that can be used to better oganize controls in your wxPython aplications.

TABLE OF CONTENTS:
  1. Organization in wxPython
  2. Box Sizers
  3. Box Sizers Continued
  4. Grid Bag Sizers
By: Peyton McCullough
Rating: starstarstarstarstar / 14
June 29, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

You probably already know how to create basic wxPython applications and position controls in them. If you don't, then this article is not for you. Take a look at A Look at wxPython.

A Few More Controls

Before we work on organizing controls, let's learn about a few more controls. Right not, we only know how to place buttons and text fields in our applications. It's difficult to make anything special with just these two controls, a menu and a few dialogs. First, let's take a look at a wxChoice control. It gives you a drop-down list of choices, which are taken from a Python list. Here's how you would make a basic wxChoice control:

wxChoice ( self, -1, choices = [ 'A', 'B', 'C', 'D' ] )

Note that I passed -1 as the control's id. This is the same as passing wxID_ANY, except, of course, that it's a bit shorter.

It's not important that we stick it in an application to test it out immediately. We'll save that for a few minutes. Our next control, wxComboBox, combines wxTextCtrl with wxChoice. It allows the user to either select an item from the list or specify his or her own text. It works similar to wxChoice:

wxComboBox ( self, -1, 'Default Text', choices = [ 'A', 'B', 'C', 'D' ] )

Next up is wxListBox. This works similar to wxChoice, except it's already expanded. Again, it works similar to wxChoice:

wxListBox ( self, -1, choices = [ 'A', 'B', 'C', 'D' ] )

Last, but not least, comes wxStaticText. Like the name suggests, it allows you to place text in your applications.

WxStaticText ( self, -1, 'A bit of text.' )



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- 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: