[PyQt] Displaying a dialog - advanced a little

Phil phil_lor at bigpond.com
Wed Apr 3 07:34:21 BST 2013


On 03/04/13 15:11, Phil wrote:
> 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.

Not only is the above import wrong, it seems that it's not needed anyway.

>
> 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_()

If I substitute the following then a dialog is displayed but not my 
dialog. So, it seems that mainwindow isn't aware of my SatelliteListDialog.

         d = QtGui.QDialog(self)

         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