Distributing your application on Windows
Creating self-contained applications on Windows is quite straight-forward but you need to make sure than you have all of the correct software installed before you start.
Python and PyQt
Please ensure that you have installed the following versions of Python and PyQt as it can not be guaranteed that the rest of the instructions will work with earlier or later versions:
- Python 3.3.0: either Python 3.3.0 Windows X86-64 MSI Installer (64-bit) or Python 3.3.0 Windows x86 MSI Installer (32-bit)
- PyQt 4.9.6: either the PyQt-Py3.3-x64-gpl-4.9.6-1.exe (64-bit Windows) or PyQt-Py3.3-x86-gpl-4.9.6-1.exe (32-bit Windows) binary package
If the above links are broken try going to the download pages on each site:
Add Python to your path
We will need to make use of the command prompt to use cx_Freeze therefore Python must be available to us as a command. The following video demonstrates how to add Python to your path.
Use the above video to add Python to your system path.
cx_Freeze is a utility that will take your Python program and convert it to a stand-alone application (.exe) file that can be run on any Windows computer.
You should download and run the cx_Freeze installer:
If the link is broken try the cx_Freeze homepage:
Creating a script for cx_Freeze
To create a stand-alone application from your program cx_Freeze needs a script to tell it what to do. Because our programs are fairly simple (in the grand scheme of things) all we need to do is make a few changes to the sample program that is provided by cx_Freeze for use with PyQt programs.
The sample script has two lines that we are interested in:
application_title = "simple_PyQt4"
main_python_file = "PyQt4app.py"
You should change the values assigned to the variables
main_python_file so that they are suitable for whatever program you wish to create a stand-alone application for. For example, the field simulation would be:
application_title = "Field Simulation"
main_python_file = "field_simulation.py"
Once you have made the necessary changes save the script and then move it so that it is in the same directory as the Python modules you want to convert to a stand-alone application.
Run the cx_Freeze script
The final step of this process is to execute the cx_Freeze script. The video demonstrates how to do this.
Use the above video to create a stand-alone application.
In this section you have see how to turn your Python program into a stand-alone application that you can distribute to other people. To do this we modified an example script to get cx_Freeze to perform the necessary operations for us. However, if your application was more complex you made need to modify the script further. The documentation for cx_Freeze should be able to point you in the right direction and there is an excellent mailing list that you can join to get assistance as well.
- Previous - Distributing your application on Mac OS X
- 1. Installing PyQt on Mac OS X
- 2. Installing PyQt on Windows
- 3. Introduction to PyQt
- 4. Graphical crop simulation
- 5. Creating a basic PyQt application
- 6. Introduction to Layouts
- 7. Radio Button Widget
- 8. Creating the layouts
- 9. Switching layouts
- 10. Adding growth functionality
- 11. Graphics and resources
- 12. Summary
- 13. Field simulation
- 14. Designing the user interface
- 15. Graphical representation of crops and animals
- 16. Resources file
- 17. Crop and animal graphical sub-classes
- 18. Graphical representation of the field
- 19. Toolbars
- 20. Introduction to event handling
- 21. Adding the drag functionality to the toolbar labels
- 22. Adding the 'drop' functionality to the field
- 23. Context Menus
- 24. Automatically growing the field
- 25. Manually growing the field
- 26. Field Report
- 27. Final Summary
- 28. Distributing your application
- 29. Distributing your application on Mac OS X
- 30. Distributing your application on Windows