562 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Should you be using QT for Python as a GUI?
Part six of an eight-part series of blogs
If you need to build a GUI system in Python, PyQt5 is probably the best choice, but don't take our word for it - read this blog and see what you think.
To get buttons (or other widgets) to do something when you click on them or change them, you listen for the signals that they emit and assign these to slots.
To show how this works, suppose that you have a simple form containing a single label and single push button:
We've called the label lblOwlMessage and the button btnShowOwlMessage.
We hide the label when the form loads (you could do this in QT Designer instead):
# hide the message to start
self.lblOwlMessage: QLabel = self.findChild(QLabel,'lblOwlMessage')
Next we create a slot to handle the event of clicking on the button (in most Microsoft applications this would be called an event-handler):
# show the hidden label
Finally, we connect the clicked signal from the push button to the show_message slot above:
# get push button to do something
self.btnShowOwlMessage: QPushButton = self.findChild(QPushButton,'btnShowOwlMessage')
The range of signals emitted by widgets is mind-boggling, but having to tie them to slots is a bit tedious.
|Parts of this blog|
25 Aytoun Street