-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.py
executable file
·82 lines (61 loc) · 2.42 KB
/
view.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
import sys
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtWidgets import (QApplication, QBoxLayout, QCheckBox, QComboBox,
QDial, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QScrollBar,
QSlider, QSpinBox, QStackedWidget, QWidget, QLCDNumber)
class ServoControls(QGroupBox):
valueChanged = pyqtSignal(int)
def __init__(self, title, parent=None):
super(ServoControls, self).__init__(title, parent)
self.slider = QSlider(Qt.Horizontal)
self.slider.setFocusPolicy(Qt.StrongFocus)
self.slider.setTickPosition(QSlider.TicksBothSides)
self.slider.setTickInterval(10)
self.slider.setSingleStep(1)
self.dial = QDial()
self.dial.setFocusPolicy(Qt.StrongFocus)
self.dial.setNotchesVisible(True)
self.lcd_display = QLCDNumber()
self.lcd_display.display(22)
self.slider.valueChanged.connect(self.dial.setValue)
self.dial.valueChanged.connect(self.lcd_display.display)
self.dial.valueChanged.connect(self.slider.setValue)
self.dial.valueChanged.connect(self.valueChanged)
boxLayout = QBoxLayout(QBoxLayout.TopToBottom)
boxLayout.addWidget(self.slider)
boxLayout.addWidget(self.dial)
boxLayout.addWidget(self.lcd_display)
boxLayout.setStretchFactor(self.dial, 20)
self.setLayout(boxLayout)
self.setMinimum(0)
self.setMaximum(100)
self.dial.setWrapping(True)
# This shit isnt even getting called
def setValue(self, value):
print("Slider Value: " + str(value))
self.slider.setValue(value)
self.dial.setValue(value)
self.lcd_display.display(value)
def setMinimum(self, value):
self.slider.setMinimum(value)
self.dial.setMinimum(value)
def setMaximum(self, value):
self.slider.setMaximum(value)
self.dial.setMaximum(value)
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
self.pan = ServoControls("Pan")
self.tilt = ServoControls("Tilt")
layout = QHBoxLayout()
layout.addWidget(self.pan)
layout.addWidget(self.tilt)
self.setLayout(layout)
self.setWindowTitle("Sliders")
self.setMinimumSize(500,300)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())