DiscreteMathematics/Lab_2/window_1.py

117 lines
4.6 KiB
Python
Raw Permalink Normal View History

2024-03-09 17:44:57 +02:00
from PyQt5 import QtCore, QtWidgets
from sys import exit
import window_2 as w_2, window_3 as w_3, window_4 as w_4
def open_window(window):
window.show()
class Window(QtWidgets.QMainWindow):
def __init__(self):
super(QtWidgets.QMainWindow, self).__init__()
self.window_2 = w_2.Window()
self.window_3 = w_3.Window()
self.window_4 = w_4.Window()
self.setWindowTitle("Вікно 1")
self.centralwidget = QtWidgets.QWidget(self)
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.full_name = QtWidgets.QLabel(self.centralwidget)
self.full_name.setText("П. І. Б:")
self.full_name.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.full_name, 0, 0, 1, 1)
self.full_name_answer = QtWidgets.QLabel(self.centralwidget)
self.full_name_answer.setText("Швед Андрій Дмитрович")
self.gridLayout.addWidget(self.full_name_answer, 0, 1, 1, 1)
self.group = QtWidgets.QLabel(self.centralwidget)
self.group.setText("Група:")
self.group.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.group, 1, 0, 1, 1)
self.group_answer = QtWidgets.QLabel(self.centralwidget)
self.group_answer.setText("ІО-23")
self.gridLayout.addWidget(self.group_answer, 1, 1, 1, 1)
self.list_number = QtWidgets.QLabel(self.centralwidget)
self.list_number.setText("Номер в списку:")
self.list_number.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.list_number, 2, 0, 1, 1)
self.list_number_answer = QtWidgets.QLabel(self.centralwidget)
self.list_number_answer.setText("30")
self.gridLayout.addWidget(self.list_number_answer, 2, 1, 1, 1)
self.task_number = QtWidgets.QLabel(self.centralwidget)
self.task_number.setText("Номер завдання:")
self.task_number.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.task_number, 3, 0, 1, 1)
self.task_number_answer = QtWidgets.QLabel(self.centralwidget)
self.task_number_answer.setText("24")
self.gridLayout.addWidget(self.task_number_answer, 3, 1, 1, 1)
self.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(self)
self.menubar.setGeometry(QtCore.QRect(0, 0, 362, 22))
self.menubar.setDefaultUp(False)
self.menu_Windows = QtWidgets.QMenu(self.menubar)
self.menu_Windows.setTitle("Вікна")
self.setMenuBar(self.menubar)
self.window_2_action = QtWidgets.QAction(self)
self.window_2_action.setText("Вікно 2")
self.menu_Windows.addAction(self.window_2_action)
self.window_3_action = QtWidgets.QAction(self)
self.window_3_action.setText("Вікно 3")
self.menu_Windows.addAction(self.window_3_action)
self.window_4_action = QtWidgets.QAction(self)
self.window_4_action.setText("Вікно 4")
self.menu_Windows.addAction(self.window_4_action)
self.menu_Windows.addSeparator()
self.exit_action = QtWidgets.QAction(self)
self.exit_action.setText("Вихід")
self.menu_Windows.addAction(self.exit_action)
self.menubar.addAction(self.menu_Windows.menuAction())
self.set_menu()
QtCore.QMetaObject.connectSlotsByName(self)
self.female_names = ["Діана", "Оксана", "Катерина", "Карина", "Антоніна"]
self.male_names = ["Андрій", "Сергій", "Микола", "Євгеній", "Олександр"]
def set_menu(self):
self.window_2_action.triggered.connect(lambda: open_window(self.window_2))
self.window_3_action.triggered.connect(lambda: self.open_window_3())
self.window_4_action.triggered.connect(lambda: self.open_window_4())
self.exit_action.triggered.connect(lambda: exit())
def open_window_3(self):
self.window_3.set_sets(self.window_2.get_set_A(), self.window_2.get_set_B(), self.female_names, self.male_names)
self.window_3.form_relations()
open_window(self.window_3)
def open_window_4(self):
self.window_4.set_sets(
self.window_3.get_granddaughter(), self.window_3.get_godmother(),
self.window_2.get_set_A(), self.window_2.get_set_B()
)
open_window(self.window_4)