Debian Codegraph @

planetary_system_stacker/Test_programs/spinbox_test.py

raw symbols SCIP
1 from sys import argv
2 from time import sleep
3
4 from PyQt5 import QtWidgets, QtCore
5 from PyQt5.QtWidgets import QApplication, QMainWindow, QProxyStyle, QStyle
6
7 class CustomStyle(QProxyStyle):
8 def styleHint(self, hint, option=None, widget=None, returnData=None):
9 if hint == QStyle.SH_SpinBox_KeyPressAutoRepeatRate:
10 return 10**6
11 elif hint == QStyle.SH_SpinBox_ClickAutoRepeatRate:
12 return 10**6
13 elif hint == QStyle.SH_SpinBox_ClickAutoRepeatThreshold:
14 # You can use only this condition to avoid the auto-repeat,
15 # but better safe than sorry ;-)
16 return 10**6
17 else:
18 return super().styleHint(hint, option, widget, returnData)
19
20 class SpinBoxTest(QtWidgets.QWidget):
21 def __init__(self):
22 super(SpinBoxTest, self).__init__()
23 self.spinBox = QtWidgets.QSpinBox(self)
24 self.spinBox.setGeometry(QtCore.QRect(9, 27, 131, 20))
25 self.spinBox.setStyle(CustomStyle())
26 self.spinBox.valueChanged.connect(self.spinbox_changed)
27
28 def spinbox_changed(self):
29 sleep(0.5)
30 print("spinbox has changed, value: " + str(self.spinBox.value()))
31
32 if __name__ == '__main__':
33 app = QtWidgets.QApplication(argv)
34 window = SpinBoxTest()
35 window.show()
36 app.exec_()