Introduction to PyQt
Event-driven programming changes how programs function. Instead of following a list of instructions in the order defined by the programmer, instructions are executed based on events that are performed by the program user.
An event could be:
- The clicking of a button
- The dragging and dropping of an item
- The selection of a command from a menu
Event-driven programming requires a graphical user interface. Therefore we are going to investigate this programming paradigm using the PyQt framework.
PyQt is the Python implementation of Qt, which is a cross-platform application and user interface framework. This means that the same code is used to generate the user interface on Windows, Mac OS X and Linux.
Qt is incredibly sophisticated and capable and it will take you a long time to become familiar with its available operations. Therefore, you will need to keep the PyQt class reference under your pillow.
PyQt requires that you have a good understanding of object-oriented programming as the framework uses this paradigm through-out. If you are not comfortable with OOP, please spend more time developing the exercises from our OOP section before attempting this section.
This tutorial is designed to introduce you to some of the main concepts that underpin PyQt and also to familiarise you with the types of components, called widgets in PyQt, that your students are likely to need whilst developing projects for A-Level.
Through this series of tutorials you will take the crop, animal and field classes that you created during the object-oriented tutorials and develop them into graphical, event-driven programs.
- 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