mardi 18 avril 2017

PyQT using multiple classes in one Form with an MDI in tab form

Good Day all,

I have been struggling with this issue for a couple days now, I am new to Python and PyQT so don't be too hard on me ;)

I have a GUI interface with an MDI in tabbed form that connects to a database with the MySQL plugin.

Each tab in the program has it's own tableview widget and each of them connect do a different table of said database.

I would like to put each tab in it's own class as each tab have completely different features and options.

I have made all the classes needed, my problem comes in where I just cannot get the extra classes (inherited) to initiate from the original class.

class MyForm(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self, parent = None):
        super(MyForm, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #OTHER CODE HERE

class Visitor(MyForm):
    def __init__(self,parent = None):
        MyForm.__init__(self, parent)  
        super(MyForm, self).__init__(parent)
        #OTHER CODE HERE


class Admin(MyForm):
    def __init__(self, parent = None):
        QtGui.QMainWindow.__init__(self, parent)
        #OTHER CODE HERE


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    if not createConnection():
        sys.exit(1)
    myapp = MyForm()
    myapp.show()
    sys.exit(app.exec_())

I have tried both with the super and the QtGui method of connecting but I cannot figure out how to call the Original Class (MyForm).

Any help is appreciated.

Thank you.






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire