A dial widget (QDial) is included in PyQT.. It looks like a volume control you often see on mix panels. It’s part of PyQt5.QtWidgets.

pyqt dial QDial

The look and feel of the QDial widget may change on operating systems. But the logic is the same on all platforms.

Related Course: Create GUI Apps with Python PyQt5

QDial

Dial Widget Example

It has a minimum and maximum which can be set with the methods setMinimum() and setMaximum().

You can set the default value with setValue(). If the value is changed you can call a method (.valueChanged.connect(self.sliderMoved)).

The current value is .value().

Example

The example below creates a dial widget window. You can copy and paste the program to test it out. PyQt5 must be installed to run the program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from PyQt5.QtWidgets import *
import sys

class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
layout = QGridLayout()
self.setLayout(layout)
self.dial = QDial()
self.dial.setMinimum(0)
self.dial.setMaximum(100)
self.dial.setValue(40)
self.dial.valueChanged.connect(self.sliderMoved)
layout.addWidget(self.dial)

def sliderMoved(self):
print("Dial value = %i" % (self.dial.value()))

app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())

If you are new to Python PyQt, then I highly recommend this book.

Download Examples