My goal is simply to switch the dialog in application to another by clicking "Next" button and and close the previous one. So, I have a starting script:
from PyQt5.QtWidgets import QApplication, QDialog
from gui.Ui_base import Ui_Base
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = QDialog()
ui = Ui_Base()
ui.setupUi(window)
window.show()
sys.exit(app.exec_())
Then it enters this dialog, it's GUI was created by pyuic5:
from PyQt5 import QtCore, QtGui, QtWidgets
from gui.Ui_scripts import Ui_Scripts
class Ui_Base(QtWidgets.QDialog):
def setupUi(self, Base):
"""Here goes a lot of code for creating gui like size, place and etc."""
self.nextButton = QtWidgets.QPushButton(Base)
self.nextButton.clicked.connect(self.openScripts)
QtCore.QMetaObject.connectSlotsByName(Base)
def openScripts(self, Base):
scriptsWindow = QDialog()
scriptsUi = Ui_Scripts()
scriptsUi.setupUi(scriptsWindow)
Base.close()
scriptsWindow.show()
scriptsWindow.exec_()
And I get an error:
File "/Users/max/Project/gui/Ui_base.py", line 125, in openScripts Base.close()
AttributeError: 'bool' object has no attribute 'close'
So, actually it does open next dialog, but doesn't hide the current one. I tried other methods of QDialog like hide() and other, but nothing works. And I don't really understang with is Base (which is a window actually) bool?? Thanks.
self.close()
? Also, should be scriptsWindow.exec_() – mdurant