Home arrow Python arrow Page 2 - Designing a Calculator in wxPython

The Plan - Python

wxPython is a library that makes it easy for Python programmers to build graphical user interfaces. Over the past few weeks, you have seen some articles covering this library. This week, you will learn how to create a simple but useful application with wxPython.

TABLE OF CONTENTS:
  1. Designing a Calculator in wxPython
  2. The Plan
  3. Creating the Layout
  4. Wiring It All Together
By: Peyton McCullough
Rating: starstarstarstarstar / 17
July 13, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The best way to organize our calculator is to use a wxGridBagSizer. Our buttons will almost be the same size and will be organized in rows and columns, so a wxGridBagSizer is perfect for the job. The wxGridBagSizer is also pretty simple to use, so that's another plus.

Our calculator isn't going to be very complex, as I mentioned before. On the first row of our calculator will be the display, which will be served by a read-only wxTextCtrl. The display will take up the entire row. The second row will contain the add to memory button, a button for the number one, a button for the number two, a button for the number three and an addition button. The third row will contain a delete from memory button, a button for the number four, a button for the number five, a button for the number six and a subtraction button. The fourth row will contain a memory recall button, a button for the number seven, a button for the number eight, a button for the number nine and a multiplication button. The fifth row will contain a wxStaticText that displays the number currently in memory, a decimal button, a zero button, a solve button and a division button. The final row will contain a two-column clear button, a backspace button, a positive/negative button and a square root button.

We'll save ourselves the pain of creating over a dozen methods by making use of event ID numbers. I'll show you how to do this once we're at that point.

Let's get to it.



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