[PyQt] Displaying a dialog

Phil phil_lor at bigpond.com
Wed Apr 3 06:11:25 BST 2013


Thank you for reading this.

The following is the main window class generated by Eric, which includes 
a method to display a dialog.

from PyQt4.QtGui import QMainWindow
from PyQt4.QtCore import pyqtSignature

from Ui_mainwindow import Ui_MainWindow

from PyQt4 import QtGui

from SatelliteListDialog import Ui_Form # this is my addition, which is 
wrong.

class MainWindow(QMainWindow, Ui_MainWindow):
     def __init__(self, parent = None):
         QMainWindow.__init__(self, parent)
         self.setupUi(self)

     def on_actionList_triggered(self):
         self.dialog = SatelliteListDialog()

         self.dialog.exec_()

This is the dialog class also generated by Eric;

from PyQt4.QtGui import QDialog
from PyQt4.QtCore import pyqtSignature

from Ui_satListDialog import Ui_Dialog

class SatelliteListDialog(QDialog, Ui_Dialog):
     def __init__(self, parent = None):
         QDialog.__init__(self, parent)
         self.setupUi(self)

My question is; how do I let the main window class know of the existence 
of my dialog?

Even though there are lots of on-line examples I'm still missing 
something basic.

-- 
Regards,
Phil


More information about the PyQt mailing list