Navigation between interface in PyQt5 and python
-
I'am new to PyQt and i faced a problem i want to navigate between forms . what i want is : when i click on button to go to an new interface the current one close automatically ( if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close ) but the problem i face the function does not work both of the interface still open,i tried to add MainWindow.hide() function does not work and i got an error witch is Error! Error due to 'Ui_Login_Dialog' object has no attribute 'hide'
this is my function
def openwindow(self): try: self.nextui = QtWidgets.QWidget() self.ui = Registration.Ui_Registration() self.ui.setupUi(self.nextui) self.nextui.show()
this is what the function give me
(
-
Hi,
That's because you should call hide on the widget that you initialised
Ui_Login_Dialog
with. -
@SGaist
i watched many tutorials and response from other forum , they use .hide() as predefined method so i do not know how to call hide
if you mean that MainWindow should be the name of the current windows ,yes it is the name of it
i generate the code using pyuic
this is my functionself.nextui = QtWidgets.QDialog() self.ui = Ui_Model_list() self.ui.setupUi(self.nextui) self.nextui.show() MainWindow.hide()
-
@lanas said in Navigation between interface in PyQt5 and python:
if i am in the Sign In interface and i clicked on a button to go to the Sign up i want the Sing in to close
,i tried to add MainWindow.hide() function
Hiding the
MainWindow
is not the thing to do if you are wanting to hide the Sign In dialog!@SGaist said in Navigation between interface in PyQt5 and python:
That's because you should call hide on the widget that you initialised Ui_Login_Dialog with.
What widget did you initialise
Ui_Login_Dialog
with? Since I see no mention ofUi_Login_Dialog
I cannot tell. I cannot have no idea what eitherRegistration.Ui_Registration()
orUi_Model_list()
are, only you know.self.ui = Registration.Ui_Registration() self.ui.setupUi(self.nextui) self.nextui.show()
If the dialog you want to hide/close is the
self.nextui
here then you will wantself.nextui.hide()
just as you haveself.nextui.show()
. -
@JonB
the Ui_Model_list() is the name of the next interface and MainWindow is the current window
the dialog i want hide is MianWindow but the function hide did not work it gives me an error (Error due to 'MainWindow' object has no attribute 'hide')
so as conclusion the next window is showing up but the first Window does not close or hide even i use close() i still face the same problem -
Interface is the keyword here: interface != widget.
You build a widget with the interface you defined but the interface itself is not a widget.