Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5 import QtCore, QtGui, QtWidgets
- class Ui_MainWindow(object):
- def setupUi(self, MainWindow):
- MainWindow.setObjectName("MainWindow")
- MainWindow.resize(800, 172)
- self.retranslateUi(MainWindow)
- QtCore.QMetaObject.connectSlotsByName(MainWindow)
- def retranslateUi(self, MainWindow):
- _translate = QtCore.QCoreApplication.translate
- MainWindow.setWindowTitle(_translate("MainWindow", "Домашка"))
- class Window(QtWidgets.QMainWindow, Ui_MainWindow):
- def __init__(self):
- super().__init__()
- self.setupUi(self)
- self.setFixedSize(640, 170)
- self.setWindowIcon(QtGui.QIcon("shapes.png"))
- self.toolBar = QtWidgets.QToolBar(self)
- self.toolBar.setObjectName("toolBar")
- self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
- self.square_btn = QtWidgets.QAction(QtGui.QIcon("square.png"), "Квадрат", self)
- self.toolBar.addAction(self.square_btn)
- self.circle_btn = QtWidgets.QAction(QtGui.QIcon("circle.png"), "Круг", self)
- self.toolBar.addAction(self.circle_btn)
- self.triangle_btn = QtWidgets.QAction(QtGui.QIcon("triangle.png"), "Треугольник", self)
- self.toolBar.addAction(self.triangle_btn)
- self.label = QtWidgets.QLabel(self)
- self.label.setGeometry(35, 35, 2000, 122)
- self.label.setStyleSheet('''font: 18pt "Times New Roman"''')
- self.label.show()
- self.square_btn.triggered.connect(self.square)
- self.circle_btn.triggered.connect(self.circle)
- self.triangle_btn.triggered.connect(self.triangle)
- def square(self):
- self.label.setText('Периметр прямоугольника: P = 2 * (a + b)\n'
- 'Площадь прямоугольника: S = a * b')
- def circle(self):
- self.label.setText('Периметр круга: P = 2 * π * R\n'
- 'Площадь круга: S = π * R²')
- def triangle(self):
- self.label.setText('Периметр треугольника: P = a + b + c\n'
- 'Площадь треугольника: S = a * b / 2')
- if __name__ == "__main__":
- import sys
- app = QtWidgets.QApplication(sys.argv)
- w = Window()
- w.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement