Radio Button Widget
The design for our user interface requires the use of radio buttons to select the appropriate crop type.
Radio buttons are created by instantiating
QRadioButton(). However, normally when using radio buttons you want to make it clear which radio buttons belong to a particular group and it is possible you may have multiple groups of radio buttons on your interface. For example, in another project you might give the option to select male or female and to select an specific age range.
In our example the final user-interface can be seen in the screenshot below. Notice the grey area surrounding the radio buttons and the instruction that is present just above the radio buttons. This shows the grouping of the buttons clearly.
Because we might want to have multiple groups of radio buttons in future we are going to create a class which will enable us to easily create groups of radio buttons from a given list of text labels for each button. This means that if you ever need radio buttons again in the future you can just reuse this class.
The class definition will be:
The video below demonstrates how to write the necessary code for this class.
Use the above video to help you create the radio button widget class.
- 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