-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.py
337 lines (282 loc) · 15.5 KB
/
design.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
import files_rc
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QGridLayout, QLabel, QLineEdit,
QMainWindow, QPushButton, QSizePolicy, QVBoxLayout,
QWidget)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(300, 500)
MainWindow.setMinimumSize(QSize(300, 500))
icon = QIcon()
icon.addFile(u":/icons/calculator.png", QSize(), QIcon.Normal, QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setStyleSheet(u"QLabel {\n"
" color: #E6E6E6;\n"
"}\n"
"\n"
"QWidget {\n"
" color: white;\n"
" background-color: #7a7a7a;\n"
" font-family: Intro;\n"
" font-size: 16pt;\n"
" font-weight: 600;\n"
"}\n"
"\n"
"QPushButton {\n"
" background-color: transparent;\n"
" border: none;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
" background-color: #666;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" background-color: #424242;\n"
"}")
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.centralwidget.setStyleSheet(u"")
self.verticalLayout = QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(u"verticalLayout")
self.lbl_temp = QLabel(self.centralwidget)
self.lbl_temp.setObjectName(u"lbl_temp")
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lbl_temp.sizePolicy().hasHeightForWidth())
self.lbl_temp.setSizePolicy(sizePolicy)
font = QFont()
font.setFamilies([u"Intro"])
font.setPointSize(16)
font.setBold(True)
self.lbl_temp.setFont(font)
self.lbl_temp.setStyleSheet(u"color: #E6E6E6;")
self.lbl_temp.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.verticalLayout.addWidget(self.lbl_temp)
self.le_entry = QLineEdit(self.centralwidget)
self.le_entry.setObjectName(u"le_entry")
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.le_entry.sizePolicy().hasHeightForWidth())
self.le_entry.setSizePolicy(sizePolicy1)
font1 = QFont()
font1.setFamilies([u"Intro"])
font1.setPointSize(40)
font1.setBold(True)
self.le_entry.setFont(font1)
self.le_entry.setCursor(QCursor(Qt.IBeamCursor))
self.le_entry.setStyleSheet(u"font-size: 40pt;\n"
"border: none;\n"
"color: white;")
self.le_entry.setMaxLength(10)
self.le_entry.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.le_entry.setReadOnly(True)
self.verticalLayout.addWidget(self.le_entry)
self.layout_buttons = QGridLayout()
self.layout_buttons.setObjectName(u"layout_buttons")
self.btn_7 = QPushButton(self.centralwidget)
self.btn_7.setObjectName(u"btn_7")
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.btn_7.sizePolicy().hasHeightForWidth())
self.btn_7.setSizePolicy(sizePolicy2)
self.btn_7.setFont(font)
self.btn_7.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_7, 2, 0, 1, 1)
self.btn_4 = QPushButton(self.centralwidget)
self.btn_4.setObjectName(u"btn_4")
sizePolicy2.setHeightForWidth(self.btn_4.sizePolicy().hasHeightForWidth())
self.btn_4.setSizePolicy(sizePolicy2)
self.btn_4.setFont(font)
self.btn_4.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_4, 3, 0, 1, 1)
self.btn_1 = QPushButton(self.centralwidget)
self.btn_1.setObjectName(u"btn_1")
sizePolicy2.setHeightForWidth(self.btn_1.sizePolicy().hasHeightForWidth())
self.btn_1.setSizePolicy(sizePolicy2)
self.btn_1.setFont(font)
self.btn_1.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_1, 4, 0, 1, 1)
self.btn_ce = QPushButton(self.centralwidget)
self.btn_ce.setObjectName(u"btn_ce")
sizePolicy2.setHeightForWidth(self.btn_ce.sizePolicy().hasHeightForWidth())
self.btn_ce.setSizePolicy(sizePolicy2)
self.btn_ce.setFont(font)
self.btn_ce.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_ce, 1, 1, 1, 1)
self.btn_clear = QPushButton(self.centralwidget)
self.btn_clear.setObjectName(u"btn_clear")
sizePolicy2.setHeightForWidth(self.btn_clear.sizePolicy().hasHeightForWidth())
self.btn_clear.setSizePolicy(sizePolicy2)
self.btn_clear.setFont(font)
self.btn_clear.setCursor(QCursor(Qt.PointingHandCursor))
self.btn_clear.setIconSize(QSize(16, 16))
self.layout_buttons.addWidget(self.btn_clear, 1, 0, 1, 1)
self.btn_sub = QPushButton(self.centralwidget)
self.btn_sub.setObjectName(u"btn_sub")
sizePolicy2.setHeightForWidth(self.btn_sub.sizePolicy().hasHeightForWidth())
self.btn_sub.setSizePolicy(sizePolicy2)
self.btn_sub.setFont(font)
self.btn_sub.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_sub, 5, 0, 1, 1)
self.btn_mul = QPushButton(self.centralwidget)
self.btn_mul.setObjectName(u"btn_mul")
sizePolicy2.setHeightForWidth(self.btn_mul.sizePolicy().hasHeightForWidth())
self.btn_mul.setSizePolicy(sizePolicy2)
self.btn_mul.setFont(font)
self.btn_mul.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_mul, 2, 3, 1, 1)
self.btn_div = QPushButton(self.centralwidget)
self.btn_div.setObjectName(u"btn_div")
sizePolicy2.setHeightForWidth(self.btn_div.sizePolicy().hasHeightForWidth())
self.btn_div.setSizePolicy(sizePolicy2)
self.btn_div.setFont(font)
self.btn_div.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_div, 1, 3, 1, 1)
self.btn_neg = QPushButton(self.centralwidget)
self.btn_neg.setObjectName(u"btn_neg")
sizePolicy2.setHeightForWidth(self.btn_neg.sizePolicy().hasHeightForWidth())
self.btn_neg.setSizePolicy(sizePolicy2)
self.btn_neg.setFont(font)
self.btn_neg.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_neg, 3, 3, 1, 1)
self.btn_add = QPushButton(self.centralwidget)
self.btn_add.setObjectName(u"btn_add")
sizePolicy2.setHeightForWidth(self.btn_add.sizePolicy().hasHeightForWidth())
self.btn_add.setSizePolicy(sizePolicy2)
self.btn_add.setFont(font)
self.btn_add.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_add, 4, 3, 1, 1)
self.btn_calc = QPushButton(self.centralwidget)
self.btn_calc.setObjectName(u"btn_calc")
sizePolicy2.setHeightForWidth(self.btn_calc.sizePolicy().hasHeightForWidth())
self.btn_calc.setSizePolicy(sizePolicy2)
self.btn_calc.setFont(font)
self.btn_calc.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_calc, 5, 3, 1, 1)
self.btn_backspace = QPushButton(self.centralwidget)
self.btn_backspace.setObjectName(u"btn_backspace")
sizePolicy2.setHeightForWidth(self.btn_backspace.sizePolicy().hasHeightForWidth())
self.btn_backspace.setSizePolicy(sizePolicy2)
self.btn_backspace.setFont(font)
self.btn_backspace.setCursor(QCursor(Qt.PointingHandCursor))
icon1 = QIcon()
icon1.addFile(u":/icons/outline_backspace_white_24dp.png", QSize(), QIcon.Normal, QIcon.Off)
self.btn_backspace.setIcon(icon1)
self.btn_backspace.setIconSize(QSize(24, 24))
self.layout_buttons.addWidget(self.btn_backspace, 1, 2, 1, 1)
self.btn_9 = QPushButton(self.centralwidget)
self.btn_9.setObjectName(u"btn_9")
sizePolicy2.setHeightForWidth(self.btn_9.sizePolicy().hasHeightForWidth())
self.btn_9.setSizePolicy(sizePolicy2)
self.btn_9.setFont(font)
self.btn_9.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_9, 2, 2, 1, 1)
self.btn_6 = QPushButton(self.centralwidget)
self.btn_6.setObjectName(u"btn_6")
sizePolicy2.setHeightForWidth(self.btn_6.sizePolicy().hasHeightForWidth())
self.btn_6.setSizePolicy(sizePolicy2)
self.btn_6.setFont(font)
self.btn_6.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_6, 3, 2, 1, 1)
self.btn_3 = QPushButton(self.centralwidget)
self.btn_3.setObjectName(u"btn_3")
sizePolicy2.setHeightForWidth(self.btn_3.sizePolicy().hasHeightForWidth())
self.btn_3.setSizePolicy(sizePolicy2)
self.btn_3.setFont(font)
self.btn_3.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_3, 4, 2, 1, 1)
self.btn_point = QPushButton(self.centralwidget)
self.btn_point.setObjectName(u"btn_point")
sizePolicy2.setHeightForWidth(self.btn_point.sizePolicy().hasHeightForWidth())
self.btn_point.setSizePolicy(sizePolicy2)
self.btn_point.setFont(font)
self.btn_point.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_point, 5, 2, 1, 1)
self.btn_8 = QPushButton(self.centralwidget)
self.btn_8.setObjectName(u"btn_8")
sizePolicy2.setHeightForWidth(self.btn_8.sizePolicy().hasHeightForWidth())
self.btn_8.setSizePolicy(sizePolicy2)
self.btn_8.setFont(font)
self.btn_8.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_8, 2, 1, 1, 1)
self.btn_5 = QPushButton(self.centralwidget)
self.btn_5.setObjectName(u"btn_5")
sizePolicy2.setHeightForWidth(self.btn_5.sizePolicy().hasHeightForWidth())
self.btn_5.setSizePolicy(sizePolicy2)
self.btn_5.setFont(font)
self.btn_5.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_5, 3, 1, 1, 1)
self.btn_2 = QPushButton(self.centralwidget)
self.btn_2.setObjectName(u"btn_2")
sizePolicy2.setHeightForWidth(self.btn_2.sizePolicy().hasHeightForWidth())
self.btn_2.setSizePolicy(sizePolicy2)
self.btn_2.setFont(font)
self.btn_2.setCursor(QCursor(Qt.PointingHandCursor))
self.layout_buttons.addWidget(self.btn_2, 4, 1, 1, 1)
self.btn_0 = QPushButton(self.centralwidget)
self.btn_0.setObjectName(u"btn_0")
sizePolicy2.setHeightForWidth(self.btn_0.sizePolicy().hasHeightForWidth())
self.btn_0.setSizePolicy(sizePolicy2)
self.btn_0.setFont(font)
self.btn_0.setCursor(QCursor(Qt.PointingHandCursor))
self.btn_0.setIconSize(QSize(16, 16))
self.layout_buttons.addWidget(self.btn_0, 5, 1, 1, 1)
self.verticalLayout.addLayout(self.layout_buttons)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"OneCalculator", None))
self.lbl_temp.setText(QCoreApplication.translate("MainWindow", u"", None))
self.le_entry.setText(QCoreApplication.translate("MainWindow", u"0", None))
self.btn_7.setText(QCoreApplication.translate("MainWindow", u"7", None))
self.btn_7.setShortcut(QCoreApplication.translate("MainWindow", u"7", None))
self.btn_4.setText(QCoreApplication.translate("MainWindow", u"4", None))
self.btn_4.setShortcut(QCoreApplication.translate("MainWindow", u"4", None))
self.btn_1.setText(QCoreApplication.translate("MainWindow", u"1", None))
self.btn_1.setShortcut(QCoreApplication.translate("MainWindow", u"1", None))
self.btn_ce.setText(QCoreApplication.translate("MainWindow", u"CE", None))
self.btn_ce.setShortcut(QCoreApplication.translate("MainWindow", u"Del", None))
self.btn_clear.setText(QCoreApplication.translate("MainWindow", u"C", None))
self.btn_sub.setText(QCoreApplication.translate("MainWindow", u"+/-", None))
self.btn_mul.setText(QCoreApplication.translate("MainWindow", u"\u00d7", None))
self.btn_mul.setShortcut(QCoreApplication.translate("MainWindow", u"*", None))
self.btn_div.setText(QCoreApplication.translate("MainWindow", u"/", None))
self.btn_div.setShortcut(QCoreApplication.translate("MainWindow", u"/", None))
self.btn_neg.setText(QCoreApplication.translate("MainWindow", u"-", None))
self.btn_neg.setShortcut(QCoreApplication.translate("MainWindow", u"-", None))
self.btn_add.setText(QCoreApplication.translate("MainWindow", u"+", None))
self.btn_add.setShortcut(QCoreApplication.translate("MainWindow", u"+", None))
self.btn_calc.setText(QCoreApplication.translate("MainWindow", u"=", None))
self.btn_calc.setShortcut(QCoreApplication.translate("MainWindow", u"=", None))
self.btn_backspace.setText("")
self.btn_backspace.setShortcut(QCoreApplication.translate("MainWindow", u"Backspace", None))
self.btn_9.setText(QCoreApplication.translate("MainWindow", u"9", None))
self.btn_9.setShortcut(QCoreApplication.translate("MainWindow", u"9", None))
self.btn_6.setText(QCoreApplication.translate("MainWindow", u"6", None))
self.btn_6.setShortcut(QCoreApplication.translate("MainWindow", u"6", None))
self.btn_3.setText(QCoreApplication.translate("MainWindow", u"3", None))
self.btn_3.setShortcut(QCoreApplication.translate("MainWindow", u"3", None))
self.btn_point.setText(QCoreApplication.translate("MainWindow", u".", None))
self.btn_point.setShortcut(QCoreApplication.translate("MainWindow", u".", None))
self.btn_8.setText(QCoreApplication.translate("MainWindow", u"8", None))
self.btn_8.setShortcut(QCoreApplication.translate("MainWindow", u"8", None))
self.btn_5.setText(QCoreApplication.translate("MainWindow", u"5", None))
self.btn_5.setShortcut(QCoreApplication.translate("MainWindow", u"5", None))
self.btn_2.setText(QCoreApplication.translate("MainWindow", u"2", None))
self.btn_2.setShortcut(QCoreApplication.translate("MainWindow", u"2", None))
self.btn_0.setText(QCoreApplication.translate("MainWindow", u"0", None))
self.btn_0.setShortcut(QCoreApplication.translate("MainWindow", u"0", None))