-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
executable file
·85 lines (73 loc) · 2.91 KB
/
gui.py
File metadata and controls
executable file
·85 lines (73 loc) · 2.91 KB
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
83
84
85
"""
XMas Tree Control for the PiHut GPIO XMas tree.
Copyright (C) 2019 Aubrey Thomas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import sys
from ledcontrol import LedControl
from PyQt5.QtWidgets import QWidget, QApplication, QGridLayout, QLabel, QComboBox, QPushButton
from multiprocessing import Process
class Gui(QWidget):
def __init__(self):
super().__init__()
self.process = False
self.controlled = LedControl()
self.ledCombo = QComboBox()
self.ledCombo.addItem("All")
j = 1
for i in range(2, 26):
self.ledCombo.addItem(str(j))
j += 1
self.valueCombo = QComboBox()
for i in range(0, 11):
self.valueCombo.addItem(str(i/10))
self.delayCombo = QComboBox()
for i in range(0, 11):
self.delayCombo.addItem(str(i/10))
self.sequenceCombo = QComboBox()
self.sequenceCombo.addItem("None")
self.sequenceCombo.addItem("Random")
self.initUI()
def initUI(self):
layout = QGridLayout()
self.setLayout(layout)
ledtext = QLabel("LED")
sequencetext = QLabel("Sequence")
delaytext = QLabel("Delay")
valuetext = QLabel("Value")
applybutton = QPushButton("Apply")
applybutton.clicked.connect(self.apply)
layout.addWidget(sequencetext, 0, 0)
layout.addWidget(ledtext, 1, 0)
layout.addWidget(delaytext, 2, 0)
layout.addWidget(valuetext, 3, 0)
layout.addWidget(self.sequenceCombo, 0, 1)
layout.addWidget(self.ledCombo, 1, 1)
layout.addWidget(self.delayCombo, 2, 1)
layout.addWidget(self.valueCombo, 3, 1)
layout.addWidget(applybutton, 4, 1)
self.setWindowTitle("XMas Tree Control")
self.setGeometry(300, 300, 500, 200)
self.show()
def apply(self):
led = self.ledCombo.currentText()
sequence = self.sequenceCombo.currentIndex()
delay = self.delayCombo.currentText()
value = self.valueCombo.currentText()
if self.process:
self.process.terminate()
self.process = Process(target=self.controlled.ledchange, args=(led, sequence, delay, value))
self.process.start()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Gui()
sys.exit(app.exec_())