-
Notifications
You must be signed in to change notification settings - Fork 1
/
Grapics.py
151 lines (134 loc) · 6.12 KB
/
Grapics.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from PyQt5 import QtCore, QtGui, QtWidgets
import config as cg
class grapics:
def __init__(self,cw,cwd,sc):
self.sc = sc
self.serial = 0
self.centralwidget = cw
self.cwd = cwd
self.background()
self.indicator()
self.status()
self.green_ring()
self.logo()
self.click_to()
def background(self):
self.background = QtWidgets.QLabel(self.centralwidget)
self.background.setGeometry(QtCore.QRect(0, 0, cg.width, cg.height))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.background.setFont(font)
self.background.setAutoFillBackground(False)
self.background.setText("")
self.background.setPixmap(QtGui.QPixmap(self.cwd+"/"+cg.background))
self.background.setScaledContents(True)
self.background.setObjectName("background")
def indicator(self):
self.indicator = QtWidgets.QLabel(self.centralwidget)
self.indicator.setGeometry(QtCore.QRect(cg.indicator_x,cg.indicator_y, cg.indicator_width, cg.indicator_height))
self.indicator.setText("")
self.indicator.setPixmap(QtGui.QPixmap(self.cwd+"/"+cg.red_indicator))
self.indicator.setScaledContents(True)
self.indicator.setObjectName("indicator")
self.indicator.show()
def status(self):
self.status = QtWidgets.QLabel(self.centralwidget)
self.status.setGeometry(QtCore.QRect(cg.width//2.7, cg.height//1.6, 11, 41))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei UI")
font.setPointSize(60)
font.setBold(True)
font.setWeight(75)
self.status.setText("STATUS <font color=\"red\"> OFF </font> ")
self.status.setFont(font)
self.status.setStyleSheet("color:rgb(255, 255, 255)")
self.status.setScaledContents(True)
self.status.setObjectName("status")
self.status.adjustSize()
def green_ring(self):
self.ring = QtWidgets.QLabel(self.centralwidget)
self.ring.setGeometry(QtCore.QRect(cg.button1_x-5, cg.button1_y-5 , 130, 130))
self.ring.setText(" ")
self.ring.setPixmap(QtGui.QPixmap(self.cwd+"/"+cg.green_ring))
self.ring.setScaledContents(True)
self.ring.setObjectName("rign")
self.ring.setEnabled(False)
def logo(self):
self.logo = QtWidgets.QLabel(self.centralwidget)
self.logo.setGeometry(QtCore.QRect(cg.width//1.20,cg.height//1.10, cg.logo_width, cg.logo_height))
self.logo.setText("")
self.logo.setPixmap(QtGui.QPixmap(self.cwd+"/"+cg.logo))
self.logo.setScaledContents(True)
self.logo.setObjectName("logo")
def click_to(self):
self.click_to = QtWidgets.QLabel(self.centralwidget)
self.click_to.setGeometry(QtCore.QRect(cg.width//2.7, cg.height-cg.height//3.5, 200, 30))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei UI")
font.setPointSize(24)
font.setWeight(75)
self.click_to.setFont(font)
self.click_to.setText("CLICK SPACE TO SWITCH ON")
self.click_to.setStyleSheet("color:rgb(255, 255, 255)")
self.click_to.setObjectName("click_to")
self.click_to.setAlignment(QtCore.Qt.AlignCenter)
self.click_to.adjustSize()
def connectedport(self):
self.port = str(self.sc.connectedPort).upper()
self.selectedPort = QtWidgets.QLabel(self.centralwidget)
self.selectedPort.setGeometry(QtCore.QRect(cg.width//2.8, cg.height//1.4 - 40, 10, 30))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei UI")
font.setPointSize(24)
font.setWeight(75)
self.selectedPort.setText("CONNECTED PORT:"+self.port)
self.selectedPort.setFont(font)
self.selectedPort.setStyleSheet("color:rgb(255, 255, 0)")
self.selectedPort.setScaledContents(True)
self.selectedPort.setObjectName("selectedPort")
self.selectedPort.hide()
self.selectedPort.adjustSize()
def availablePorts(self):
self.ports = self.sc.find_com_port()
self.showPorts = QtWidgets.QLabel(self.centralwidget)
self.showPorts.setGeometry(QtCore.QRect(cg.width//2.3, cg.height//2.3, cg.button6_width, cg.button6_height))
font = QtGui.QFont()
font.setFamily("Microsoft Tai Le")
font.setPointSize(24)
font.setBold(True)
font.setWeight(75)
self.showPorts.setFont(font)
self.showPorts.setStyleSheet("color:rgb(255, 255, 255)")
self.showPorts.setText("AVAILABLE PORTS:\n" +str(self.ports).upper())
self.showPorts.setAlignment(QtCore.Qt.AlignCenter)
if self.ports is None:
self.showPorts.setText("AVAILABLE PORTS:\n"+" "+"NONE")
self.showPorts.adjustSize()
self.showPorts.hide()
self.showPorts.setObjectName("showPorts")
def portIndicator(self):
self.portIndicator = QtWidgets.QLabel(self.centralwidget)
self.portIndicator.setGeometry(QtCore.QRect(cg.width-50, 20, 25,25))
self.portIndicator.setText("")
self.portIndicator.setPixmap(QtGui.QPixmap(self.cwd+"/"+cg.noUsb))
self.portIndicator.setScaledContents(True)
self.portIndicator.setObjectName("portIndicator")
def showCredits(self):
self.credits = QtWidgets.QLabel(self.centralwidget)
self.credits.setGeometry(QtCore.QRect(cg.width//2.8, cg.height/2, 11, 41))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei UI")
font.setPointSize(26)
font.setBold(True)
font.setWeight(75)
name = "MUSABBIR AHMED ARRAFI"
email = "musabbir.arrafi@gmail.com"
self.credits.setText(name+"\n"+email)
self.credits.setFont(font)
self.credits.setStyleSheet("color:rgb(255, 255, 255)")
self.credits.setScaledContents(True)
# self.credits.setStyleSheet("QLabel { background-color : black;color:rgb(255, 255, 255)}")
self.credits.setObjectName("credits")
self.credits.setAlignment(QtCore.Qt.AlignCenter)
self.credits.adjustSize()