For Windows, there are four tools to install: a C++ compiler, the Qt C++ application development framework, the Python interpreter and its accompanying libraries, and PyQt4 (which includes SIP in the Windows binary package). We assume that the GPL editions are being used, in which case the only C++ compiler that will work with Qt is MinGW. (Visual C++ can be used only with the commercial editions of Qt and PyQt and the instructions for installing them are provided when you buy them.)
★SIP is a tool used to create "bindings" that allow C++ classes to be accessible from Python.
At the time of this writing, an all-in-one package was under development. This package is an executable setup file that is expected to contain all the PyQt modules (except the QtDesigner module), QScintilla, the translation and Qt Designer support tools, the documentation and examples, the SQLite database, and support for .png, .svg, ,gif,and .jpeg image formats. This package is complete and self-contained and requires no other software to be installed apart from Python itself. However, the package is not extensible. If you are learning or evaluating PyQt for the first time, using this package is probably the easiest way to begin. You can always uninstall it and install the precise set of components you need later on when you have gained experience. When the package is available it will be on the Web site http://riverbankcomputing.com. After intalling Python, simply download and execute the all-in-one package to install everything else.
In the instructions that follow, we are using Windows XP Home edition and are installing each component separately. There may be differences for other Windows versions, but they should not be so different that they can't be worked out from what's written here.
The files required for installation are MinGW-3.4.2.exe, qt-win-opensource-4.2.3-mingw.exe, python-2.5.1.msi, and PyQt-gpl-4.2-Py2.5-Qt4.2.3.exe. The book's examples are in the file pyqtbook.zip.
The first item to get is PyQt itself. This is because the versions of Python and Qt you will need depend on the version of PyQt you get. Go to http://www. riverbankcomputing.co.uk/pyqt/download.php and download the binary package PyQt-gpl-4.2-Py2.5-Qt4.2.3.exe. The filename has version numbers embedded in it and these may differ from the ones shown here: The first number is the PyQt version which must be at least 4.2 to get the most out of this book; the second number is the Python version that you must get; and the third number is the Qt version—you must download this precise version.
Now get Qt. Go to http://www.trolltech.com/developer/downloads/qt/index and click the Qt/Windows Open Source Edition link; at the bottom of the page, download qt-win-opensource-4.2.3-mingw.exe. The version number should exactly match the one in the PyQt package name, so if, for example, you downloaded PyQt-gpl-4.3-Py2.5-Qt4.3.1.exe, you will need to get qt-win-opensource-4.3.1-mingw.exe.
The MinGW C++ compiler is also available from Trolltech's Web site, but from a completely different URL. Go to ftp://ftp.trolltech.com/misc/ and download MingGW-3.4.2.exe. (You can skip this step and let the Qt installer download the compiler for you, but by downloading it yourself you have the package in hand, which is more convenient for installing on other machines, or for restoring if your Windows installation goes bad.)
Now it is time to get Python. Go to http://www.python.org/download and download one of the Windows installers. (The ones at the top of the page do not include the source code; this is fine, as you need the source only if you want to modify Python itself.) There may be more than one Windows installer; click a hardware-specific one such as the AMD64 or Itanium one if that matches your machine's processor; otherwise click the first one—for example, "Python 2.5.1 Windows installer". Save the installer to disk; this will give you a Microsoft Installer file—for example, python-2.5.1.msi. Note that the first two parts of the version number must match the equivalent part of the PyQt version number; so for PyQt-gpl-4.2-Py2.5-Qt4.2.3.exe, any Python 2.5 version is acceptable, such as Python 2.5, or Python 2.5.1, for example.
If you want to run the examples that are shown in the book or you want to see the model answers to the exercises, you can unzip the pyqtbook.zip file available from http://www.qtrac.eu/pyqtbook.html.
Now that all the pieces are at hand, you can perform the installation. The order of installation is important, and is different from the downloading order. (You needed to download PyQt first, to make sure you got the right versions of Python and Qt; but for installing you must start with the C++ compiler, and finish by installing PyQt.) We will assume that the versions are those mentioned earlier, but obviously use whichever versions you downloaded and adjust accordingly.
Figure A.1 The MinGW and Qt installers on Windows
If you did not download the MinGW installer, either because you have the compiler already installed or because you want the Qt installer to fetch and install it for you, skip to the next paragraph. Otherwise, start up the MinGW installer (e.g., double-click MinGW-3.4.2.exe), and follow the installer's instructions. The installer's first screen is shown on the left in Figure A.1. The only decision that you must make is where to install MinGW. We have assumed that you accepted the default of C:\MinGW; but you can put it anywhere. If you do not use the standard location, though, make a note of its path since you will need it when you install Qt.
To install Qt, start up its installer by double-clicking qt-win-opensource-4.2.3-mingw.exe (or whichever version you downloaded). The installer's first screen is shown on the right in Figure A.1. The instructions are easy to follow, and again, we have assumed that you have accepted the default directory (e.g., C:\Qt\4.2.3). When you get to the "MinGW Installation" screen, if you put MinGW in the standard location, the "Previously installed MinGW" path should be correct. If it is not, or if you installed MinGW in a nonstandard location, you must type in its path or use the browse button (...) to locate it. If you did not install MinGW, check the "Download and install minimal MinGW" checkbox so that the Qt installer can fetch and install it for you.
Unfortunately, the GPL Qt installer does not add Qt to the path; this means that applications that depend on the Qt DLLs, such as QtCore4.dll, QtGui4.dll, QtXml4.dll, and so on, or that depend on the MinGW DLL, mingwm10.dll, will not find them. Since PyQt applications depend on these libraries, you must manually add the path to them so that double-clicking a PyQt .pyw application will work. Without this path, any PyQt program you attempt to run will not work, and instead an error message box will pop up, such as, "pythonw.exe -Unable To Locate Component", that says it can't find mingwm10.dll.
Click Start^Control Panel, then click System, to pop up the System Properties dialog. Click the Advanced tab, then the Environment Variables button (near the bottom of the dialog). Click the Path variable in the "System variables" section (in the bottom half of the dialog), and then click Edit.
The Edit System Variable dialog, as shown in Figure A.2, has the Windows path. Be very careful not to delete the existing path! If you delete it by mistake, click Cancel, and then try editing the path again. Press End to deselect the path and to put the text cursor at the far right of the line edit, then add the text ";C:\Qt\4.2.3\bin". The leading semicolon is essential; obviously, use the version number of the Qt you actually installed, if it's different from the one shown here. This path works for all the Qt DLLs and for the MinGW DLL (since the Qt installer copies it into the Qt bin directory).
You are now ready to install Python. Start up the Python installer by double-clicking python-2.5.1.msi or whichever other .msi file you downloaded. The installer's first screen is shown on the left in Figure A.3. The installer is straightforward to use; the only information you need to type in is Python's path if you don't want to use the default of C:\Python25. If you use a nonstandard path, keep a note of it since you will have to type it into the PyQt installer. If you are desperate for disk space you don't have to install the test suite or the utility scripts, but we assume that you keep all the other components complete, including Tcl/Tk. Once Python has been installed, the installer may ask you to reboot—you should do so before going on to install PyQt.
Figure A.3 The Python and PyQt installers on Windows
Now you can install PyQt4 itself. Start up the PyQt installer by double-clicking PyQt-gpl-4.2-Py2.5-Qt4.2.3.exe, or whichever version of PyQt you downloaded. The installer's first screen is shown on the right in Figure A.3. If you installed Python in a nonstandard location you must enter the correct location in the Choose Install Location screen—PyQt is installed as a Python extension, so its libraries are placed inside the Python directories. (For this reason, if you ever want to uninstall Python, you should uninstall PyQt first, then Python.)
PyQt is the last tool that must be installed to have everything set up and working. To test things, click Start—>All Programs—PyQt GPL v4.2—Examples and Demos. This launches a PyQt version of the standard Qt demo application. From inside this application you can run many of the demo applications that are supplied with PyQt. The source code to the demos, and to many other PyQt examples, are normally installed in C:\Program Files\PyQt4\examples.
If you downloaded the book's examples, you might like to unzip pyqtbook.zip in C: to get a C:\pyqt directory with all the book's examples, along with model answers to the exercises, categorized by chapter. In the C:\pyqt directory itself you will find mkpyqt.py and makepyqt.pyw; these utilities are explained on page 207. If you want to try out any of the examples before reading the book, make sure that you run makepyqt.pyw first. (When you run makepyqt.pyw, set its path to C:\pyqt, check its Recurse checkbox, and then click the Build button. Now all the examples will be ready to run.)
That completes the installation for Windows, and is sufficient for PyQt GUI programming. But if you also want to write some console applications, or to sometimes run PyQt applications in a console (which can be useful for debugging), a few more steps will make this much more convenient.
Click Start—All Programs—Accessories—Windows Explorer. Once Windows Explorer is running, navigate to My Computer\Local Disk (C:)\Documents and Settings, and then to the directory that has your username, and inside that, navigate to Start Menu\Programs\Accessories. Copy and paste the Console (or MS-DOS Prompt) shortcut, and rename the copy "Console (PyQt)". Right-click the new Console (PyQt) shortcut to edit its properties. On the General page, change the Target to cmd.exe /k C:\pyqt\pyqt.bat. Now when you want a PyQt-friendly console you can click Start—>All Programs—Accessories—Console (PyQt) and the console that appears will automatically run C:\pyqt\pyqt.bat. This batch file contains only two lines:
You might like to edit this file (using a plain text editor) to add a third line containing a cd command—for example, cd C:\pyqt—so that the console starts up in a convenient directory. If you installed MinGW or Python in nonstandard locations you will need to edit this file anyway, to put in their correct paths.
You are now ready to write and run PyQt applications on your Windows machine—and they will run unchanged on Mac OS X and Linux too!
Was this article helpful?
The main focus of this report is to show how to get involved in video marketing on the run, how to rank quickly on YouTube and Google using FREE semi-automatic tools and services. QUICKLY AND FREE. I will show methods and techniques I use to rank my videos, as well as free resources and tools to make video clips, to get backlinks and free traffic.