class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(523, 346)
font = QtGui.QFont()
font.setKerning(False)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(180, 10, 170, 20))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setStyleSheet("")
self.label.setObjectName("label")
self.toolButton = QtWidgets.QToolButton(self.centralwidget)
self.toolButton.setGeometry(QtCore.QRect(30, 40, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
font.setPointSize(8)
self.toolButton.setFont(font)
self.toolButton.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.toolButton.setShortcut("")
self.toolButton.setAutoRepeatDelay(300)
self.toolButton.setObjectName("toolButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(320, 40, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_2.setFont(font)
self.pushButton_2.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_2.setShortcut("")
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(30, 80, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_3.setFont(font)
self.pushButton_3.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_3.setShortcut("")
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_4.setGeometry(QtCore.QRect(320, 80, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_4.setFont(font)
self.pushButton_4.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_4.setShortcut("")
self.pushButton_4.setObjectName("pushButton_4")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(180, 130, 170, 20))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_5.setGeometry(QtCore.QRect(30, 170, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_5.setFont(font)
self.pushButton_5.setAutoFillBackground(False)
self.pushButton_5.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_5.setShortcut("")
self.pushButton_5.setAutoRepeat(False)
self.pushButton_5.setAutoDefault(False)
self.pushButton_5.setObjectName("pushButton_5")
self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_7.setGeometry(QtCore.QRect(320, 170, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_7.setFont(font)
self.pushButton_7.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_7.setShortcut("")
self.pushButton_7.setObjectName("pushButton_7")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(220, 220, 170, 20))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
font.setPointSize(10)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_6.setGeometry(QtCore.QRect(30, 250, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_6.setFont(font)
self.pushButton_6.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);\n"
"")
self.pushButton_6.setShortcut("")
self.pushButton_6.setObjectName("pushButton_6")
self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_8.setGeometry(QtCore.QRect(192, 250, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_8.setFont(font)
self.pushButton_8.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_8.setShortcut("")
self.pushButton_8.setObjectName("pushButton_8")
self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_9.setGeometry(QtCore.QRect(354, 250, 161, 25))
font = QtGui.QFont()
font.setFamily("MS UI Gothic")
self.pushButton_9.setFont(font)
self.pushButton_9.setStyleSheet("background-color: rgb(91, 9, 191);\n"
"color: rgb(255, 255, 255);")
self.pushButton_9.setShortcut("")
self.pushButton_9.setObjectName("pushButton_9")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 523, 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)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Калькулятор физических величин"))
self.label.setText(_translate("MainWindow", "Механика"))
self.toolButton.setText(_translate("MainWindow", "Кинематика"))
self.pushButton_2.setText(_translate("MainWindow", "Гидростатика"))
self.pushButton_3.setText(_translate("MainWindow", "Динамика"))
self.pushButton_4.setText(_translate("MainWindow", "Статика"))
self.label_2.setText(_translate("MainWindow", "Термодинамика"))
self.pushButton_5.setText(_translate("MainWindow", "Состояний"))
self.pushButton_7.setText(_translate("MainWindow", "Процессов"))
self.label_3.setText(_translate("MainWindow", "Оптика"))
self.pushButton_6.setText(_translate("MainWindow", "Геометрическая"))
self.pushButton_8.setText(_translate("MainWindow", "Волновая "))
self.pushButton_9.setText(_translate("MainWindow", "Квантовая"))
self.pushButton.clicked.connect(self.ravnd)
self.pushButton_2.clicked.connect(self.centr)
self.pushButton_3.clicked.connect(self.prd)
self.pushButton_4.clicked.connect(self.chst)
def ravnd(self): # функция, которая будет выполняться после нажатия кнопки
a = self.lineEdit.text()
b = self.lineEdit_2.text()
c = int(a) / int(b)
self.textEdit.append(str(c))
def centr(self):
a = self.lineEdit_7.text()
b = self.lineEdit_8.text()
c = int(a) ** 2 / int(b)
self.textEdit_2.append(str(c))
def prd(self):
a = self.lineEdit_3.text()
b = self.lineEdit_4.text()
c = int(b) / int(a)
self.textEdit_3.append(str(c))
def chst(self):
a = self.lineEdit_5.text()
b = self.lineEdit_6.text()
c = int(a) / int(b)
self.textEdit_4.append(str(c))
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
import sys
from calcf import Ui_MainWindow
from kinematika import Ui_Dialog
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
def openkinem():
global Dialog
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
ui.toolButton.clicked.connect(openkinem)
sys.exit(app.exec_())
global Dialog
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
from PyQt5 import QtWidgets
from modules.main_module import main_module
import sys
# ------------------------------------------------------------------------------- #
#
# ------------------------------------------------------------------------------- #
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = main_module()
window.show_window()
sys.exit(app.exec_())
from PyQt5 import QtWidgets, QtSql, QtCore, QtGui
import ui.ui_main as ui_main
from modules.win1_module import win1_module
from modules.win2_module import win2_module
# ------------------------------------------------------------------------------- #
#
# ------------------------------------------------------------------------------- #
class main_module(QtWidgets.QMainWindow):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
QtWidgets.QMainWindow.__init__(self, parent)
self.ui = ui_main.Ui_MainWindow()
self.ui.setupUi(self)
self.ui.btn_win1.clicked.connect(
self.on_show_win1)
self.ui.btn_win2.clicked.connect(
self.on_show_win2)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_show_win1(self):
"""
"""
self.win1 = win1_module(self)
self.win1.show()
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_show_win2(self):
"""
"""
self.win2 = win2_module(self)
self.win2.show()
# --------------------------------------------------------------------------- #
# Показывыет главное окно программы
# Отображение по середине экрана
# --------------------------------------------------------------------------- #
def show_window(self):
"""
"""
desktop = QtWidgets.QApplication.desktop()
x = (desktop.width() - self.width()) // 2
y = (desktop.height() - self.height()) // 2
self.move(x, y)
self.show()
from PyQt5 import QtWidgets, QtCore, QtSql, QtGui
import ui.ui_win1 as ui_win1
# ------------------------------------------------------------------------------- #
#
#
# ------------------------------------------------------------------------------- #
class win1_module(QtWidgets.QDialog):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
super().__init__(parent=parent)
self.setWindowModality(QtCore.Qt.WindowModal)
self.setWindowFlags(self.windowFlags() |
QtCore.Qt.WindowMaximizeButtonHint)
self.ui = ui_win1.Ui_Dialog()
self.ui.setupUi(self)
self.main = parent
self.setWindowTitle("Окно №1")
self.ui.btn_close.clicked.connect(
self.on_close)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_close(self):
"""
"""
self.close()
from PyQt5 import QtWidgets, QtCore, QtSql, QtGui
import ui.ui_win2 as ui_win2
# ------------------------------------------------------------------------------- #
#
#
# ------------------------------------------------------------------------------- #
class win2_module(QtWidgets.QDialog):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
super().__init__(parent=parent)
self.setWindowModality(QtCore.Qt.WindowModal)
self.setWindowFlags(self.windowFlags() |
QtCore.Qt.WindowMaximizeButtonHint)
self.ui = ui_win2.Ui_Dialog()
self.ui.setupUi(self)
self.main = parent
self.setWindowTitle("Окно №2")
self.ui.btn_close.clicked.connect(
self.on_close)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_close(self):
"""
"""
self.close()