Reputation: 833
HI I am trying to develop a plugin. I have used PyQt5 designed to create the Gui.I want to know how to launch a new window after I click on a button.
This is the interface I have created using PyQt5 Designer. Here is the Image link
Once the Activate button is clicked, Activation key sent dialog box opens as shown in the above image. Once the OK button is clicked, i need to open a new window as shown
Here is main ui_dialog.py
from .gisedify_support_dialog_login import Ui_Dialog
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'gisedify_support_dialog_base.ui'))
class GisedifySupportDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
"""Constructor."""
super(GisedifySupportDialog, self).__init__(parent)
# Set up the user interface from Designer through FORM_CLASS.
# After self.setupUi() you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
def open_login_dialog(self):
self.nd = Login_Dialog(self)
self.nd.show()
class Login_Dialog(QtWidgets.QDialog,Ui_Dialog):
def __init__(self, parent=None):
super(Login_Dialog, self).__init__(parent)
This is my UI_Dialog class
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
....
....
self.pushButton.setObjectName("pushButton")
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Enter activation key"))
self.pushButton.setText(_translate("Dialog", "Login"))
I am calling the loginwindow using
GisedifySupportDialog().open_login_dialog()
The above code does nothing and no error also. Please help me in opening login window when OK button is clicked from main window
Upvotes: 0
Views: 2252
Reputation: 27
Try this:
def open_login_dialog(self):
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.exec_()
Upvotes: 2