Если вам нравится, что он показывает 0.02
Вам, вероятно, потребуется установить точность шага в десятичных разрядах
, например: setSingleStep (0.02)
import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel,
QVBoxLayout, QDoubleSpinBox)
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.initWindow()
def initWindow(self):
vBoxLayout = QVBoxLayout()
self.label = QLabel("Current Value", self)
self.label.move(60, 60)
vBoxLayout.addWidget(self.label)
self.spinBox = QDoubleSpinBox(self)
self.spinBox.move(60, 30)
self.spinBox.setMinimum(0)
self.spinBox.setMaximum(12)
self.spinBox.setSingleStep(0.02)
self.spinBox.valueChanged.connect(self.valueChanged)
def valueChanged(self):
self.label.setText("Current Value {:.2f}".format(self.spinBox.value()))
if __name__ == '__main__':
aplicacion = QApplication(sys.argv)
window = Window()
window.setGeometry(100, 100, 220, 100)
window.show()
sys.exit(aplicacion.exec_())