PyQt5: Opening a new window through uic.loadUi

  pyqt5, python-3.x

I have something similar to the following. I want to open a new window from the top tool bar, this is archive, currently a new window opens but it is small and blank, it is not the one saved as archive.ui as produced by qtdesigner. The window’s object name is ArchiveWindow.

class GUI(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        uic.loadUi('gui.ui', self)
        self.actionSingle_Archive.triggered.connect(self.archive)
        ...

        def archive(self):
            self.window = QtWidgets.QMainWindow()
            uic.loadUi('archive.ui')
            self.window.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = GUI()
    win.show()
    sys.exit(app.exec())

Source: Python-3x Questions

LEAVE A COMMENT