从另一个类调用小部件

时间:2017-10-24 18:09:31

标签: python-2.7 pyqt4 qt-designer

我在Qt Designer中创建了两个文件,每个文件都会生成一个窗口。当我在window_one中按一个按钮时,window_two会打开。在第三个文件中,我导入了两个类,然后我构建了应用程序的逻辑部分。但现在我想获取有关window_one中的小部件的信息并在window_two中使用它,但我不知道该怎么做

from Window_ONE import window_one_ui
from Window_TWO import window_two_ui

class window_two(QtGui.QWidget, window_two_ui):
    def __init__(self, parent=None):
        super(window_two, self).__init__(parent)
        self.setupUi(self)

    def AnyFunction(self)
        if self.QCheckBox.isChecked()==True #Here is the problem. 
            do somthing                     #QCheckBox was defined in the window_one_ui



class window_one(QtGui.QWidget, window_one_ui):    
    def __init__(self, parent=None):
        super(window_one, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setupUi(self)

    def Open_window_two(self):
        self.plotWindow = window_two()
        self.plotWindow.show()

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Form = window_one()
    Form.show()
    sys.exit(app.exec_())

如何从windows_one调用变量?

0 个答案:

没有答案