# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'name.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(403, 421)
MainWindow.setStyleSheet("QPushButton{\n"
"font-size: 30px;\n"
" font: 30pt \"Rubik\";\n"
"\n"
"}")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(0, 0, 401, 101))
font = QtGui.QFont()
font.setFamily("Rubik")
self.label.setFont(font)
self.label.setStyleSheet("background-color: rgb(225, 255, 176);")
self.label.setObjectName("label")
self.btn_0 = QtWidgets.QPushButton(self.centralwidget)
self.btn_0.setGeometry(QtCore.QRect(100, 310, 101, 71))
self.btn_0.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_0.setObjectName("btn_0")
self.btn_minus = QtWidgets.QPushButton(self.centralwidget)
self.btn_minus.setGeometry(QtCore.QRect(200, 310, 101, 71))
self.btn_minus.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_minus.setObjectName("btn_minus")
self.btn_plus = QtWidgets.QPushButton(self.centralwidget)
self.btn_plus.setGeometry(QtCore.QRect(0, 310, 101, 71))
self.btn_plus.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_plus.setObjectName("btn_plus")
self.btn_ravno = QtWidgets.QPushButton(self.centralwidget)
self.btn_ravno.setGeometry(QtCore.QRect(300, 310, 101, 71))
self.btn_ravno.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_ravno.setObjectName("btn_ravno")
self.btn_1 = QtWidgets.QPushButton(self.centralwidget)
self.btn_1.setGeometry(QtCore.QRect(0, 100, 101, 71))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(30)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
self.btn_1.setFont(font)
self.btn_1.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_1.setObjectName("btn_1")
self.btn_6 = QtWidgets.QPushButton(self.centralwidget)
self.btn_6.setGeometry(QtCore.QRect(200, 170, 101, 71))
self.btn_6.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_6.setObjectName("btn_6")
self.btn_5 = QtWidgets.QPushButton(self.centralwidget)
self.btn_5.setGeometry(QtCore.QRect(100, 170, 101, 71))
self.btn_5.setStatusTip("")
self.btn_5.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_5.setObjectName("btn_5")
self.btn_9 = QtWidgets.QPushButton(self.centralwidget)
self.btn_9.setGeometry(QtCore.QRect(200, 240, 101, 71))
self.btn_9.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_9.setObjectName("btn_9")
self.btn_2 = QtWidgets.QPushButton(self.centralwidget)
self.btn_2.setGeometry(QtCore.QRect(100, 100, 101, 71))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(30)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
self.btn_2.setFont(font)
self.btn_2.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_2.setObjectName("btn_2")
self.btn_7 = QtWidgets.QPushButton(self.centralwidget)
self.btn_7.setGeometry(QtCore.QRect(0, 240, 101, 71))
self.btn_7.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_7.setObjectName("btn_7")
self.btn_4 = QtWidgets.QPushButton(self.centralwidget)
self.btn_4.setGeometry(QtCore.QRect(0, 170, 101, 71))
self.btn_4.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_4.setObjectName("btn_4")
self.btn_8 = QtWidgets.QPushButton(self.centralwidget)
self.btn_8.setGeometry(QtCore.QRect(100, 240, 101, 71))
self.btn_8.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_8.setObjectName("btn_8")
self.btn_c = QtWidgets.QPushButton(self.centralwidget)
self.btn_c.setGeometry(QtCore.QRect(300, 100, 101, 71))
self.btn_c.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_c.setObjectName("btn_c")
self.btn_delen = QtWidgets.QPushButton(self.centralwidget)
self.btn_delen.setGeometry(QtCore.QRect(300, 240, 101, 71))
self.btn_delen.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_delen.setObjectName("btn_delen")
self.btn_mnozh = QtWidgets.QPushButton(self.centralwidget)
self.btn_mnozh.setGeometry(QtCore.QRect(300, 170, 101, 71))
self.btn_mnozh.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_mnozh.setObjectName("btn_mnozh")
self.btn_3 = QtWidgets.QPushButton(self.centralwidget)
self.btn_3.setGeometry(QtCore.QRect(200, 100, 101, 71))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(30)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
self.btn_3.setFont(font)
self.btn_3.setStyleSheet("background-color: rgb(177, 255, 129);")
self.btn_3.setObjectName("btn_3")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 403, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.add_functions()
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Calculator"))
self.label.setText(_translate("MainWindow", "0"))
self.btn_0.setText(_translate("MainWindow", "0"))
self.btn_minus.setText(_translate("MainWindow", "-"))
self.btn_plus.setText(_translate("MainWindow", "+"))
self.btn_ravno.setText(_translate("MainWindow", "="))
self.btn_1.setText(_translate("MainWindow", "1"))
self.btn_6.setText(_translate("MainWindow", "6"))
self.btn_5.setText(_translate("MainWindow", "5"))
self.btn_9.setText(_translate("MainWindow", "9"))
self.btn_2.setText(_translate("MainWindow", "2"))
self.btn_7.setText(_translate("MainWindow", "7"))
self.btn_4.setText(_translate("MainWindow", "4"))
self.btn_8.setText(_translate("MainWindow", "8"))
self.btn_c.setText(_translate("MainWindow", "C"))
self.btn_delen.setText(_translate("MainWindow", "/"))
self.btn_mnozh.setText(_translate("MainWindow", "*"))
self.btn_3.setText(_translate("MainWindow", "3"))
def add_functions(self):
self.btn_0.clicked.connect(lambda:self.write_number(self.btn_0.text()))
self.btn_1.clicked.connect(lambda: self.write_number(self.btn_1.text()))
self.btn_2.clicked.connect(lambda: self.write_number(self.btn_2.text()))
self.btn_3.clicked.connect(lambda: self.write_number(self.btn_3.text()))
self.btn_4.clicked.connect(lambda: self.write_number(self.btn_4.text()))
self.btn_5.clicked.connect(lambda: self.write_number(self.btn_5.text()))
self.btn_6.clicked.connect(lambda: self.write_number(self.btn_6.text()))
self.btn_7.clicked.connect(lambda: self.write_number(self.btn_7.text()))
self.btn_8.clicked.connect(lambda: self.write_number(self.btn_8.text()))
self.btn_9.clicked.connect(lambda: self.write_number(self.btn_9.text()))
self.btn_plus.clicked.connect(lambda: self.write_number(self.btn_plus.text()))
self.btn_delen.clicked.connect(lambda: self.write_number(self.btn_delen.text()))
self.btn_mnozh.clicked.connect(lambda: self.write_number(self.btn_mnozh.text()))
self.btn_ravno.clicked.connect(lambda: self.write_number(self.btn_ravno.text()))
self.btn_minus.clicked.connect(lambda: self.write_number(self.btn_minus.text()))
self.btn_c.clicked.connect(lambda: self.write_number(self.btn_c.text()))
def write_number(self,number):
self.label_resailt.setText(self.label_resault.text()+number)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())