May 2019
Intermediate to advanced
542 pages
13h 37m
English
Now that we've taken care of the GPIO side, let's create our PyQt GUI. In MainWindow.__init__(), add in the following code:
self.tcl = ThreeColorLed(8, 10, 12)
Here, we're creating a ThreeColorLed instance using the pin numbers that we connected to our breadboard. Remember that the class uses the BOARD numbers by default, so 8, 10, and 12 are the correct values here. If you want to use the BCM numbers, be sure to specify this in the constructor arguments.
Now let's add a color picker dialog:
ccd = qtw.QColorDialog() ccd.setOptions( qtw.QColorDialog.NoButtons | qtw.QColorDialog.DontUseNativeDialog) ccd.currentColorChanged.connect(self.set_color) self.setCentralWidget(ccd)
Typically, we invoke a color dialog by calling ...
Read now
Unlock full access