[Tutor] Classes in multiple files

Phil phil_lor at bigpond.com
Thu Apr 4 01:14:21 CEST 2013


Thank you for reading this.

The recent question relating to classes has prompted to ask this one.

I have a main window class and a dialog class and they are defined in 
separate files. I'm attempting to display the dialog when a menu item is 
selected in the main window but it doesn't work because, I think, the 
main window class isn't aware of the dialog class in another file.

This is the beginning of the main window class;

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

And this is the beginning of the dialog class;

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

If this was C++ then I'd need to include a class header and so I'm 
thinking that an import statement is needed in the main window class 
referring to the dialog class. Import SatelliteListDialog isn't correct.

There are many on-line examples that deal with displaying dialogs, 
however, both classes are in the same file rather that being separated.

No doubt, this is a trivial question but, as yet, I have not found an 
answer.

-- 
Regards,
Phil


More information about the Tutor mailing list