May 2019
Intermediate to advanced
542 pages
13h 37m
English
Our SoundWidget class is going to be a QWidget object that manages a single sound sample. When finished, it will allow us to load or record an audio sample, play it back looped or as a one-shot, and control its volume and playback position.
Above the MainWindow constructor, let's create the class and give it a layout:
class SoundWidget(qtw.QWidget): def __init__(self): super().__init__() self.setLayout(qtw.QGridLayout()) self.label = qtw.QLabel("No file loaded") self.layout().addWidget(self.label, 0, 0, 1, 2)
The first thing we've added is a label that will display the name of the sample file the widget has loaded. The next thing we need is a button to control the playback. Instead of just a plain push button, ...
Read now
Unlock full access