从另一个文件创建mdiArea子窗口

时间:2016-08-09 10:52:01

标签: python python-3.5 pyqt5 qmdiarea

我在主窗口类中的mdiArea中创建子窗口(应该在不同的Python文件中创建)时遇到了麻烦。

My_app.py

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

# importing my main app GUI
from GUIs import main_window_GUI

# importing different application modules
from Modules import login_module
from Modules.diagnostic_center_module import Diagnostic_center

class My_app(QMainWindow, main_window_GUI.Ui_main_window):
    def __init__(self):
        QMainWindow.__init__(self)
        main_window_GUI.Ui_main_window.__init__(self)
        self.setupUi(self)

        # Now I'm calling a function from *diagnostic_center_module*
        # in order to create and show a sub window within 
        # mdiArea (which is a part of Ui_main_window) called *body*
        self.show_diagnostic_center

diagnostic_center_module.py

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

# importing my sub window GUI
from GUIs import diagnostic_center_GUI

class Diagnostic_center(object):
    def show_diagnostic_center(self):
        self.diagnostic_center_subwindow = QWidget
        self.diagnostic_center_subwindow.setObjectName("diagnostic_center_subwindow")
        self.container = QFrame(self.diagnostic_center_subwindow)

        diagnostic_GUI = diagnostic_center_GUI.Ui_diagnostic_center()
        diagnostic_GUI.setupUi(diagnostic_GUI)

        self.container.setCurrentWidget(diagnostic_GUI)

        # this part should create a sub window within mdiArea called body
        # whic is located inside My_app.py file.
        self.body.addSubWindow(self.diagnostic_center_subwindow)
        self.diagnostic_center_subwindow.showNormal()

我指望你帮助我们帮助我解决这个问题。非常感谢。

0 个答案:

没有答案