S
S
Surv168932019-01-04 17:26:02
Python
Surv16893, 2019-01-04 17:26:02

Multiple Inheritance Python?

0HKno14--4Y.jpg
Good afternoon! Tell me how to make classes inherit as shown in the picture. The ProfilerApp class is initialization in PyQt5, Object class describes the interface ( LoginWindowClass is the login window, MainWindowClass is the main window of the application), and ConnectionClass is the connection to the server

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey6661313, 2019-01-26
@Sergey6661313

In python and in qt, inheritance means different things...
in python , it means that children are born with the same methods as the parents, and in qt , it means just a link in the descendants about who gave birth to them. and the parents just have a list of their children..
Due to the fact that in your case I don’t see the point of the ConnectionClass object having ProfilerAppClass methods, I’ll assume that you just need references to children and parents.

class MainWindowClass(QMainWindow):
    def __init__(self, parent)
    super().__init__(parent)
    self.parent = parent  # - просто создаём себе переменную где указываем родителя. Который передаётся при создании экземпляра. 


class LoginWindowClass(QWidget):
    def __init__(self, parent)
        super().__init__(parent)
        self.parent = parent

class ConnectionClass(QTcpServer):
    def __init__(self, parent)
        super().__init__(parent)
        self.parent = parent

class ProfilerAppClass():
    def __init__():
        self.childs = {  # и список чайлдов...  хотя QT по идее сам должен был составить подобный список, и вообще не понятно зачем отдельный клас, можно сразу использовать словарь...
            "MainWindow": MainWindowClass(self)
            "LoginWindow": LoginWindowClass(self)
            "Connection": ConnectionClass(self)
        }
        
ProfilerApp = ProfilerAppClass()
ProfilerApp.childs.get("MainWindow").show()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question