-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
176 lines (154 loc) · 6.03 KB
/
ui.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QVBoxLayout
from PyQt5.QtGui import QFont
from qfluentwidgets import FluentIcon
from qfluentwidgets import (TextEdit, RadioButton, PrimaryPushButton,
LineEdit, MessageBox, HyperlinkButton, ScrollBar)
from calculate import e, sss, sas, aas, asa, hl
class FLabel(QLabel):
def __init__(self, text):
super().__init__()
self.setText(text)
self.setFont(QFont("Microsoft YaHei UI", 10))
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('Triangles')
self.h = QHBoxLayout(self)
self.vb = QVBoxLayout(self)
self.vbo = QVBoxLayout(self)
self.r1h = QHBoxLayout(self)
self.r2h = QHBoxLayout(self)
self.h_ea = QHBoxLayout(self)
self.h_eb = QHBoxLayout(self)
self.h_ec = QHBoxLayout(self)
self.h_aa = QHBoxLayout(self)
self.h_ab = QHBoxLayout(self)
self.h_ac = QHBoxLayout(self)
self.r_sss = RadioButton('SSS', self)
self.r_sss.setChecked(True)
self.r_sas = RadioButton('SAS', self)
self.r_aas = RadioButton('AAS', self)
self.r_asa = RadioButton('ASA', self)
self.r_hl = RadioButton('HL', self)
self.l_ea = FLabel('Edge a =')
self.l_eb = FLabel('Edge b =')
self.l_ec = FLabel('Edge c =')
self.l_aa = FLabel('∠A (°) =')
self.l_ab = FLabel('∠B (°) =')
self.l_ac = FLabel('∠C (°) =')
self.l_r = TextEdit(self)
self.l_r.setFont(QFont("Microsoft YaHei UI", 13))
self.l_r.setText('There is nothing to show.\nPlease input something.')
self.scb = ScrollBar(Qt.Vertical, self.l_r)
self.e_ea = LineEdit(self)
self.e_eb = LineEdit(self)
self.e_ec = LineEdit(self)
self.e_aa = LineEdit(self)
self.e_ab = LineEdit(self)
self.e_ac = LineEdit(self)
self.pb = PrimaryPushButton('Process', self)
self.lb = HyperlinkButton(
url='https://github.com/Unqualified-Developers/Triangles',
text='Source Code Repository', icon=FluentIcon.GITHUB
)
self.r_sss.clicked.connect(self.sss_c)
self.r_sas.clicked.connect(self.sas_c)
self.r_aas.clicked.connect(self.aas_c)
self.r_asa.clicked.connect(self.asa_c)
self.r_hl.clicked.connect(self.hl_c)
self.pb.clicked.connect(self.process)
self.r1h.addWidget(self.r_sss)
self.r1h.addWidget(self.r_sas)
self.r1h.addWidget(self.r_aas)
self.r2h.addWidget(self.r_asa)
self.r2h.addWidget(self.r_hl)
self.h_ea.addWidget(self.l_ea)
self.h_ea.addWidget(self.e_ea)
self.h_eb.addWidget(self.l_eb)
self.h_eb.addWidget(self.e_eb)
self.h_ec.addWidget(self.l_ec)
self.h_ec.addWidget(self.e_ec)
self.h_aa.addWidget(self.l_aa)
self.h_aa.addWidget(self.e_aa)
self.h_ab.addWidget(self.l_ab)
self.h_ab.addWidget(self.e_ab)
self.h_ac.addWidget(self.l_ac)
self.h_ac.addWidget(self.e_ac)
self.vb.addLayout(self.r1h)
self.vb.addLayout(self.r2h)
self.vb.addLayout(self.h_ea)
self.vb.addLayout(self.h_eb)
self.vb.addLayout(self.h_ec)
self.vb.addLayout(self.h_aa)
self.vb.addLayout(self.h_ab)
self.vb.addLayout(self.h_ac)
self.vbo.addWidget(self.l_r)
self.vb.addWidget(self.pb)
self.vb.addWidget(self.lb)
self.h.addLayout(self.vb)
self.h.addWidget(QLabel(" "))
self.h.addLayout(self.vbo)
self.e_aa.setEnabled(False)
self.e_ab.setEnabled(False)
self.e_ac.setEnabled(False)
def sss_c(self):
self.e_aa.setEnabled(False)
self.e_ab.setEnabled(False)
self.e_ac.setEnabled(False)
self.e_ea.setEnabled(True)
self.e_eb.setEnabled(True)
self.e_ec.setEnabled(True)
def sas_c(self):
self.e_aa.setEnabled(False)
self.e_ab.setEnabled(False)
self.e_ac.setEnabled(True)
self.e_ea.setEnabled(True)
self.e_eb.setEnabled(True)
self.e_ec.setEnabled(False)
def aas_c(self):
self.e_aa.setEnabled(True)
self.e_ab.setEnabled(True)
self.e_ac.setEnabled(False)
self.e_ea.setEnabled(True)
self.e_eb.setEnabled(False)
self.e_ec.setEnabled(False)
def asa_c(self):
self.e_aa.setEnabled(False)
self.e_ab.setEnabled(True)
self.e_ac.setEnabled(True)
self.e_ea.setEnabled(True)
self.e_eb.setEnabled(False)
self.e_ec.setEnabled(False)
def hl_c(self):
self.e_aa.setEnabled(False)
self.e_ab.setEnabled(False)
self.e_ac.setEnabled(False)
self.e_ea.setEnabled(True)
self.e_eb.setEnabled(False)
self.e_ec.setEnabled(True)
self.e_ac.setText('90')
def process(self):
try:
if self.r_sss.isChecked():
self.l_r.setText(sss(e(self.e_ea.text()),
e(self.e_eb.text()),
e(self.e_ec.text())))
elif self.r_sas.isChecked():
self.l_r.setText(sas(e(self.e_ea.text()),
e(self.e_ac.text()),
e(self.e_eb.text())))
elif self.r_aas.isChecked():
self.l_r.setText(aas(e(self.e_aa.text()),
e(self.e_ab.text()),
e(self.e_ea.text())))
elif self.r_asa.isChecked():
self.l_r.setText(asa(e(self.e_ab.text()),
e(self.e_ea.text()),
e(self.e_ac.text())))
elif self.r_hl.isChecked():
self.l_r.setText(hl(e(self.e_ea.text()),
e(self.e_ec.text())))
except Exception:
m = MessageBox("Process", "This is not a triangle.", self)
m.exec_()