Develop a Desktop Software using PyQt

Develop a Desktop Software using PyQt - Mac, Window, Linux (Cross-Platform)

Introduction

When some people try to make desktop application using Python, they need to make Graphical User Interfaces at first. Although there are many GUI Framework for python, I recommend Qt. Qt is a GUI Framework now owened by Digia, available as free as open source software. and There are PyQt which is the wrapper for Qt. Originally there was many wrapper - Jambi, Qyoto, etc..(Actually, Qt can be wrapped by any new language, becuase it is made using C++) - but currently, Only Pyqt is chasing Qt's Latest version.
Anyway, Qt's Advantage is two.

  • Easy to use, particularly for beginners
  • Cross-Platform (Window, Linux, Mac)
and Wrapping Python make Qt's advantages much be strong. 
  • Easy -> More Easy
  • Cross-Plaform too. 
  • Easy Debug
  • Easy Test.
In this post, I will post How to develop a application with PyQt.

Setting Environment for PyQt Development

Introduction PyInstaller


Whatever we develop, we should try to check as follows:

  • how to build it easily
  • how to deploy it 
  • what is dependency for it 
Originally, to deploy Qt Application, we could just build it. (sometimes it need to build qt's library using another way)



Python is script, so there was no way to deploy it except distutil. but many people have been trying to find way to deploy it like another language, PyInstaller was born. 

certainly, there are other deploy tool for python, I think PyInstaller is very strong. 

Its feature is as follows:

Features
  • Packaging of Python programs into standard executables, that work on computers without Python installed.
  • Multiplatform: works under
  • Windows (32-bit and 64-bit),
  • Linux (32-bit and 64-bit),
  • Mac OS X (32-bit and 64-bit),
  • experimentally Solaris and AIX.
  • Multiversion: works under any version of Python from 2.4 up to 2.7.
  • Flexible packaging mode:
  • Single directory: build a directory containing an executable plus all the external binary modules (.dll, .pyd, .so) used by the program.
  • Single file: build a single executable file, totally self-contained, which runs without any external dependency.
  • Custom: you can automate PyInstaller to do whatever packaging mode you want through a simple script file in Python.
  • Explicit intelligent support for many 3rd-packages (for hidden imports, external data files, etc.), to make them work with PyInstaller out-of-the-box (seeSupportedPackages).
  • Full single-file EGG support: required .egg files are automatically inspected for dependencies and bundled, and all the egg-specific features are supported at runtime as well (entry points, etc.).
  • Partial directory EGG support: required .egg directories are automatically inspected for dependencies and bundled, but egg-specific features will not work at runtime.
  • Support for automatic binary packing through the well-known UPX compressor.
  • Optional console mode (see standard output and standard error at runtime).
  • Windows-specific features:
  • Full automatic support for CRTs: no need to manually distribute MSVCR*.DLL, redist installers, manifests, or anything else; trueone-file applications that work everywhere! (seeFeatures/Python26Win)
  • Selectable executable icon.
  • Fully configurable version resource section and manifests in executable.
  • Support for building COM servers.
  • Mac-specific features:
From www.pyinstaller.org 


Anyway, we will use it to deploy a application.

Install Python


Its Latest release version is 2.7.6 - http://www.python.org/download/releases/2.7.6We should Install its 32bit version http://www.python.org/ftp/python/2.7.6/python-2.7.6.msibecause pyinstaller not support 64bit yet.


Install PyQt 

Qt5 has released Last year, and recently PyQt5 has released. but I didn't check whether pyinstaller support it or not. so we will use PyQt4.


Intall PyWin32 - its wrapper for windows api. we sometimes need to it on windows.

we can check whether it is installed successfully as follows:

$python
>import sip
>import PyQt4
>

if you don't see any error messages, I can sure PyQt4 is installed successfully.

Above Instruction is available windows and mac. 

ok, that's it for today. I will post about workflow for PyQt, see you.

댓글