import sys
from PyQt5 import QtWidgets, QtGui, QtCore, Qt
from PyQt5.QtGui import QIcon
import ui_1
from task import Task
class ExampleApp(QtWidgets.QMainWindow, ui_1.Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.add_task.clicked.connect(self.add_task_f)
# добавление задачи
def add_task_f(self):
self.suppliers_and_add_tasks.addTab(Task().new_task(), self.task_name.toPlainText())
def main():
app = QtWidgets.QApplication(sys.argv)
window = ExampleApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1479, 781)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QtCore.QSize(1479, 781))
MainWindow.setMaximumSize(QtCore.QSize(1479, 781))
font = QtGui.QFont()
font.setPointSize(9)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setMinimumSize(QtCore.QSize(1479, 781))
self.centralwidget.setMaximumSize(QtCore.QSize(1479, 781))
self.centralwidget.setObjectName("centralwidget")
self.all_tabs = QtWidgets.QTabWidget(self.centralwidget)
self.all_tabs.setGeometry(QtCore.QRect(0, 0, 1479, 781))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.all_tabs.sizePolicy().hasHeightForWidth())
self.all_tabs.setSizePolicy(sizePolicy)
self.all_tabs.setMinimumSize(QtCore.QSize(1479, 781))
self.all_tabs.setMaximumSize(QtCore.QSize(1479, 781))
self.all_tabs.setObjectName("all_tabs")
self.all = QtWidgets.QWidget()
self.all.setObjectName("all")
self.supliers_and_tasks = QtWidgets.QWidget()
self.supliers_and_tasks.setObjectName("supliers_and_tasks")
self.suppliers_and_add_tasks = QtWidgets.QTabWidget(self.supliers_and_tasks)
self.suppliers_and_add_tasks.setGeometry(QtCore.QRect(0, 0, 1479, 761))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.suppliers_and_add_tasks.sizePolicy().hasHeightForWidth())
self.suppliers_and_add_tasks.setSizePolicy(sizePolicy)
self.suppliers_and_add_tasks.setMinimumSize(QtCore.QSize(1479, 761))
self.suppliers_and_add_tasks.setMaximumSize(QtCore.QSize(1479, 761))
self.suppliers_and_add_tasks.setObjectName("suppliers_and_add_tasks")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.suppliers_and_add_tasks.addTab(self.tab, "")
self.all_tabs.addTab(self.supliers_and_tasks, "")
MainWindow.setCentralWidget(self.centralwidget)
self.groupBox_7 = QtWidgets.QGroupBox(self.tab)
self.groupBox_7.setGeometry(QtCore.QRect(670, 10, 471, 511))
self.groupBox_7.setObjectName("groupBox_7")
self.task_name = QtWidgets.QTextBrowser(self.groupBox_7)
self.task_name.setGeometry(QtCore.QRect(80, 60, 151, 25))
self.task_name.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth)
self.task_name.setReadOnly(False)
self.task_name.setAcceptRichText(False)
self.task_name.setObjectName("task_name")
self.add_task = QtWidgets.QPushButton(self.tab)
self.add_task.setGeometry(QtCore.QRect(750, 530, 121, 23))
self.add_task.setObjectName("add_task")
from PyQt5 import QtWidgets, QtGui, QtCore, Qt
class Task:
def __init__(self):
super().__init__()
self.tab_2 = QtWidgets.QTabWidget()
self.tab_2.setObjectName("tab_2")
self.start_task = QtWidgets.QPushButton(self.tab_2)
self.start_task.setGeometry(QtCore.QRect(300, 510, 171, 23))
font = QtGui.QFont()
font.setPointSize(9)
self.start_task.setFont(font)
self.start_task.setObjectName("start_task")
self.start_task.clicked.connect(self.test)
def new_task(self):
return self.tab_2
def test(self):
print('111')
class ExampleApp(QtWidgets.QMainWindow, test_ui.Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
...
def main():
app = QtWidgets.QApplication(sys.argv)
window = ExampleApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()
использую QMainWindow за основу