Thursday, May 20, 2010

Learn Quickly Creating Professional Looking Desktop Application Using Python - Part 2 of 7




Installing and testing our installations

Quick links to other parts of this blog series:
Part-1 | Part-2 | Part-3 | Part-4 | Part-5 | Part-6 | Part-7 

Basically, all the 5 programs we needed for this tutorial (as listed above) have fairly simple installation procedure. Generally all you have to do is download the Windows Binaries respectively and run it to install on your PC.
Note: you most install “Python” first before installing “wxPython” and “Py2exe”, because they are both python’s extensions/libraries.

Now let’s be sure that all we have installed are working perfectly;
For wxFormBuilder and InnoSetup Compiler, you should see their icons on your desktop or windows start pane. Launch the programs to be sure they are working!

For Python 2.x, wxPython, and Py2exe; you will have to follow the procedures below to verify they are installed properly.

~~ Open command prompt and type python and hit enter. If you got error like on image-1 below, then python is not recognized on your PC. Now do any of Option1 or Option2
~~ Option1: assuming you installed python on this path “C:\Python27” run this code below on the command prompt to fix it automatically (note: if your path is different, replace to the correct path).

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User" )

~~ Option2: If Option1 above didn’t work for you, add the path manually as follow; open your computer’s “Control Panel” and follow 1-6 as shown on image-2 below (i.e.: Control Panel > System and Security > System > Advanced system settings > Advance > EnvironmentVariable...).
~~ On the window that opens after clicking “EnvironmentVariable...”, select “Path” then click on “Edit” and add your python path starting with semi-column as shown on image-3. Then click on “Ok” three times to apply the path.
~~ If all went well, retyping python on the command prompt will open a Python Shell as shown in image-4 below.

Still on the Python Shell, to test for wxpython and py2exe installations just type import wx and hit enter then type import py2exe and hit enter. If no any message is displayed as in image-5, then you are good to go your installations are in order.



Thanks for reading!

If you can't wait for the next blog post, download the completed tutorial as a .pdf file from this link: http://umaryusuf.com/wxpy/wxPython-gui-tutorial.pdf

Learn Quickly Creating Professional Looking Desktop Application Using Python - Part 1 of 7

I have done this tutorial series elsewhere, but now I decide to repeat it on my blog.... This post is the part 1. Enjoy! 

Learn Quickly Creating Professional Looking Desktop Application Using Python2.7/wxPython, wxFormBuilder, Py2exe and InnoSetup Take your ability to develop powerful applications for desktop to the next level today.

Introduction
Quick links to other parts of this blog series:
Part-1 | Part-2 | Part-3 | Part-4 | Part-5 | Part-6 | Part-7


This tutorial will show you how to design and build a fully-functional desktop Graphical User Interface (GUI) application for maths Expression Evaluation using a combination of Python 2.x, wxPython, wxFormBuilder, Py2exe and InnoSetup Compiler. The app we will build is going to be a mini calculator that can perform valid Mathematical Expression Operations of addition, subtraction, multiplication, and division.

First of all, I will use python syntax (leveraging on the eval() python function) to make a Console/CLI (Command Line Interface) program, then convert it into a Graphical User Interface (GUI) app so that users have much more control of it.
I will use the CLI program to explain some python basic syntax for those who may be struggling with understanding of the python basics.


If you feel you need to learn/refresh your python knowledge, then I recommend reading this book “A Bytes of Python” by Swaroop C H.

By the way, some popular software vendors using what we are about to learn to power there software include;- Taskcoach.org, Bittorrent.com, Editra.org, and dropbox.com (Source: www.wikipedia.org/wiki/WxPython)

Basic requirements for this class are:-
~ Basic knowledge of Python programming – I will do my best to simplify the process of this tutorial as much as possible, so everyone will be able to follow along.
~ A Windows Operating System (OS) machine (other OS users can follow along as well) - I am using 32-bit OS computer using the Windows-7 operating system.
~ Python2 interpreter, Text editor, wxPython library, wxFormBuilder, Py2Exe, and Inno Setup Compiler – I will show you how to get and install all of these software soon.

Before we start installing and configuring the software we will be using, let me quickly explain what each of them will be used for and where to get/download them;-

Python 2.x interpreter
Python is an easy to learn, dynamic and powerful modern programming language. Two similar but incompatible versions of Python are in widespread use (Python2.x and Python3.x). Pls note that we will use Python2.x for this class, download the version for your OS below.

wxPython
wxPython is a free GUI toolkit which can be used to build Python GUIs. It is a wrapper for the cross-platform C++ GUI API wxWidgets. Some other GUI library/toolkits for Python include; Tkinter, PySide/PyQt, Kivy and PyGTK

Py2exe
Py2Exe is a Python Distutils extension which converts python scripts into executable windows programs, able to run without requiring a python installation. Some other Python extension/library which converts python scripts into executable programs are; PyInstaller, Py2app, cx_Freeze, bbFreeze, and vendorID

wxFormBuilder
wxFormBuilder is a free Python GUI constructor toolkit for wxWidgets GUI design which can be used to build Python GUIs. Similar python GUI constructor toolkits are wxGlade, Boa Constructor, PythonCard and wxDesigner

InnoSetup Compiler
Inno Setup is used to create installer for Windows programs. Similar programs are NSIS and WiX
Download link: www.innosetup.com

For sure, you also need a text editor if you don’t have one already, you can get NotePad++ at: www.notepad-plus-plus.org

Hope you enjoyed this class? See you next time!