May 2019
Intermediate to advanced
542 pages
13h 37m
English
By this point in this book, creating a PyQt GUI to display a couple of numbers should be a walk in the park. Just to make things interesting and to create a stylish look, we're going to use a widget that we haven't talked about yet—QLCDNumber.
First, create a base widget in MainWindow.__init__(), as follows:
widget = qtw.QWidget() widget.setLayout(qtw.QFormLayout()) self.setCentralWidget(widget)
Now, let's apply some of the styling skills that we learned in Chapter 6, Styling Qt Applications:
p = widget.palette() p.setColor(qtg.QPalette.WindowText, qtg.QColor('cyan')) p.setColor(qtg.QPalette.Window, qtg.QColor('navy')) p.setColor(qtg.QPalette.Button, qtg.QColor('#335')) p.setColor(qtg.QPalette.ButtonText, qtg.QColor('cyan')) ...Read now
Unlock full access