-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·191 lines (183 loc) · 10.4 KB
/
main.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.setWindowModality(QtCore.Qt.NonModal)
MainWindow.resize(560, 435)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QtCore.QSize(560, 435))
MainWindow.setMaximumSize(QtCore.QSize(560, 435))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("calculator_icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.button_7 = QtGui.QPushButton(self.centralwidget)
self.button_7.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_7.setObjectName(_fromUtf8("button_7"))
self.gridLayout.addWidget(self.button_7, 2, 0, 1, 1)
self.button_9 = QtGui.QPushButton(self.centralwidget)
self.button_9.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_9.setObjectName(_fromUtf8("button_9"))
self.gridLayout.addWidget(self.button_9, 2, 2, 1, 1)
self.button_3 = QtGui.QPushButton(self.centralwidget)
self.button_3.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_3.setObjectName(_fromUtf8("button_3"))
self.gridLayout.addWidget(self.button_3, 6, 2, 1, 1)
self.button_1 = QtGui.QPushButton(self.centralwidget)
self.button_1.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_1.setObjectName(_fromUtf8("button_1"))
self.gridLayout.addWidget(self.button_1, 6, 0, 1, 1)
self.parenthesis_close = QtGui.QPushButton(self.centralwidget)
self.parenthesis_close.setFocusPolicy(QtCore.Qt.NoFocus)
self.parenthesis_close.setObjectName(_fromUtf8("parenthesis_close"))
self.gridLayout.addWidget(self.parenthesis_close, 4, 5, 1, 1)
self.button_8 = QtGui.QPushButton(self.centralwidget)
self.button_8.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_8.setObjectName(_fromUtf8("button_8"))
self.gridLayout.addWidget(self.button_8, 2, 1, 1, 1)
self.divide = QtGui.QPushButton(self.centralwidget)
self.divide.setFocusPolicy(QtCore.Qt.NoFocus)
self.divide.setObjectName(_fromUtf8("divide"))
self.gridLayout.addWidget(self.divide, 2, 3, 1, 1)
self.button_6 = QtGui.QPushButton(self.centralwidget)
self.button_6.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_6.setObjectName(_fromUtf8("button_6"))
self.gridLayout.addWidget(self.button_6, 4, 2, 1, 1)
self.add = QtGui.QPushButton(self.centralwidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.add.sizePolicy().hasHeightForWidth())
self.add.setSizePolicy(sizePolicy)
self.add.setFocusPolicy(QtCore.Qt.NoFocus)
self.add.setObjectName(_fromUtf8("add"))
self.gridLayout.addWidget(self.add, 6, 3, 2, 1)
self.remainder = QtGui.QPushButton(self.centralwidget)
self.remainder.setFocusPolicy(QtCore.Qt.NoFocus)
self.remainder.setObjectName(_fromUtf8("remainder"))
self.gridLayout.addWidget(self.remainder, 7, 2, 1, 1)
self.button_2 = QtGui.QPushButton(self.centralwidget)
self.button_2.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_2.setObjectName(_fromUtf8("button_2"))
self.gridLayout.addWidget(self.button_2, 6, 1, 1, 1)
self.reset_button = QtGui.QPushButton(self.centralwidget)
self.reset_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.reset_button.setObjectName(_fromUtf8("reset_button"))
self.gridLayout.addWidget(self.reset_button, 2, 5, 1, 1)
self.decimal = QtGui.QPushButton(self.centralwidget)
self.decimal.setFocusPolicy(QtCore.Qt.NoFocus)
self.decimal.setObjectName(_fromUtf8("decimal"))
self.gridLayout.addWidget(self.decimal, 7, 1, 1, 1)
self.equals = QtGui.QPushButton(self.centralwidget)
self.equals.setFocusPolicy(QtCore.Qt.NoFocus)
self.equals.setObjectName(_fromUtf8("equals"))
self.gridLayout.addWidget(self.equals, 7, 4, 1, 2)
self.button_0 = QtGui.QPushButton(self.centralwidget)
self.button_0.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_0.setObjectName(_fromUtf8("button_0"))
self.gridLayout.addWidget(self.button_0, 7, 0, 1, 1)
self.square_root = QtGui.QPushButton(self.centralwidget)
self.square_root.setFocusPolicy(QtCore.Qt.NoFocus)
self.square_root.setObjectName(_fromUtf8("square_root"))
self.gridLayout.addWidget(self.square_root, 6, 5, 1, 1)
self.button_4 = QtGui.QPushButton(self.centralwidget)
self.button_4.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_4.setObjectName(_fromUtf8("button_4"))
self.gridLayout.addWidget(self.button_4, 4, 0, 1, 1)
self.parenthesis_open = QtGui.QPushButton(self.centralwidget)
self.parenthesis_open.setFocusPolicy(QtCore.Qt.NoFocus)
self.parenthesis_open.setObjectName(_fromUtf8("parenthesis_open"))
self.gridLayout.addWidget(self.parenthesis_open, 4, 4, 1, 1)
self.button_5 = QtGui.QPushButton(self.centralwidget)
self.button_5.setFocusPolicy(QtCore.Qt.NoFocus)
self.button_5.setObjectName(_fromUtf8("button_5"))
self.gridLayout.addWidget(self.button_5, 4, 1, 1, 1)
self.minus = QtGui.QPushButton(self.centralwidget)
self.minus.setFocusPolicy(QtCore.Qt.NoFocus)
self.minus.setObjectName(_fromUtf8("minus"))
self.gridLayout.addWidget(self.minus, 6, 4, 1, 1)
self.clear_button = QtGui.QPushButton(self.centralwidget)
self.clear_button.setFocusPolicy(QtCore.Qt.NoFocus)
self.clear_button.setObjectName(_fromUtf8("clear_button"))
self.gridLayout.addWidget(self.clear_button, 2, 4, 1, 1)
self.multiply = QtGui.QPushButton(self.centralwidget)
self.multiply.setFocusPolicy(QtCore.Qt.NoFocus)
self.multiply.setObjectName(_fromUtf8("multiply"))
self.gridLayout.addWidget(self.multiply, 4, 3, 1, 1)
self.lineEdit = QtGui.QLineEdit(self.centralwidget)
self.lineEdit.setFocusPolicy(QtCore.Qt.NoFocus)
self.lineEdit.setText(_fromUtf8(""))
self.lineEdit.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.gridLayout.addWidget(self.lineEdit, 1, 0, 1, 6)
self.output_window = QtGui.QTextBrowser(self.centralwidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.output_window.sizePolicy().hasHeightForWidth())
self.output_window.setSizePolicy(sizePolicy)
self.output_window.setFocusPolicy(QtCore.Qt.NoFocus)
self.output_window.setObjectName(_fromUtf8("output_window"))
self.gridLayout.addWidget(self.output_window, 0, 0, 1, 6)
self.horizontalLayout_2.addLayout(self.gridLayout)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 560, 26))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Calculator", None))
self.button_7.setText(_translate("MainWindow", "7", None))
self.button_9.setText(_translate("MainWindow", "9", None))
self.button_3.setText(_translate("MainWindow", "3", None))
self.button_1.setText(_translate("MainWindow", "1", None))
self.parenthesis_close.setText(_translate("MainWindow", ")", None))
self.button_8.setText(_translate("MainWindow", "8", None))
self.divide.setText(_translate("MainWindow", "/", None))
self.button_6.setText(_translate("MainWindow", "6", None))
self.add.setText(_translate("MainWindow", "+", None))
self.remainder.setText(_translate("MainWindow", "%", None))
self.button_2.setText(_translate("MainWindow", "2", None))
self.reset_button.setText(_translate("MainWindow", "AC", None))
self.decimal.setText(_translate("MainWindow", ".", None))
self.equals.setText(_translate("MainWindow", "=", None))
self.button_0.setText(_translate("MainWindow", "0", None))
self.square_root.setText(_translate("MainWindow", "√", None))
self.button_4.setText(_translate("MainWindow", "4", None))
self.parenthesis_open.setText(_translate("MainWindow", "(", None))
self.button_5.setText(_translate("MainWindow", "5", None))
self.minus.setText(_translate("MainWindow", "-", None))
self.clear_button.setText(_translate("MainWindow", "CLR", None))
self.multiply.setText(_translate("MainWindow", "*", None))