So I've started learning python with pyside for GUI development, I have been using the QT Designer for speed and converting the .ui files to .py
I currently have a "main window" ui and an "about" ui (main window was setup as a main window and about was an empty dialog)
How do I open the about dialog from the main window? The following code opens the main window from my main.py
class MainWindow(QMainWindow, mainwindow.Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
app = QApplication(sys.argv)
form = MainWindow()
form.show()
app.exec_()
that all works fine, it brings up the main window. In my main window there are menu items, one of which is an "about" selection when the user clicks this I want it to bring up the other dialog ui I created, how can I do this?
In the mainwindow.py (converted from ui) there are these references:
self.actionAbout_mailer_0_0_1 = QtGui.QAction(MainWindow)
self.actionAbout_mailer_0_0_1.setObjectName("actionAbout_mailer_0_0_1")
self.menuAbout.addAction(self.actionAbout_mailer_0_0_1)
And about.py (converted from ui) looks like this:
from PySide import QtCore, QtGui
class About_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.aboutLbl = QtGui.QLabel(Dialog)
self.aboutLbl.setGeometry(QtCore.QRect(110, 40, 171, 16))
self.aboutLbl.setObjectName("aboutLbl")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.aboutLbl.setText(QtGui.QApplication.translate("Dialog", "Mailer version 0.0.1 by .....", None, QtGui.QApplication.UnicodeUTF8))
I figure I need to create a new function inside mainwindow.py that when called opens the about dialog, I have no idea what to put in that function, I'm also confused about the slots and connections, if someone could help me out with some example code that would be great.
EDIT:
I figured out the function part of the code, still figuring out how to connect to menu but I connected to a button press which executes this method which then opens everything fine:
def openAbout(self):
aboutDialog = QtGui.QDialog(self)
aboutUi = about.About_Dialog()
aboutUi.setupUi(aboutDialog)
aboutDialog.show()