import sys from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout from PyQt5.QtCore import Qt from PyQt5.QtGui import QColor, QPalette from gui.robot import ChangeRobot from gui.status import Status from gui.imitator import Imitator class RightPanel(QWidget): def __init__(self, panels): super().__init__() layout = QVBoxLayout() for panel in panels: # panel.setFixedHeight(200) layout.addWidget(panel) self.setLayout(layout) self.initUI() def initUI(self): palette = self.palette() palette.setColor(QPalette.Window, QColor(169, 169, 169)) # DarkGray self.setAutoFillBackground(True) self.setPalette(palette) class MainPanel(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): palette = self.palette() palette.setColor(QPalette.Window, QColor(255, 255, 255)) # White self.setAutoFillBackground(True) self.setPalette(palette) class MainContentComponent(QWidget): def __init__(self, **kwargs): super().__init__() robotArgs = kwargs.get("robotPanel", {}) robotPanel = ChangeRobot(**robotArgs) statusArgs = kwargs.get("statusPanel", {}) statusPanel = Status(**statusArgs) imitatorArgs = kwargs.get("imitatorPanel", {}) imitatorPanel = Imitator(**imitatorArgs) self.rightPanel = RightPanel( panels=[ statusPanel, robotPanel, imitatorPanel ] ) self.mainPanel = MainPanel() layout = QHBoxLayout() layout.addWidget(self.mainPanel) layout.addWidget(self.rightPanel) self.setLayout(layout) self.setFixedSize(800, 600) self.initUI() def initUI(self): palette = QPalette() palette.setColor(QPalette.Background, QColor(240, 240, 240)) self.setPalette(palette) def resizeEvent(self, event): width = self.width() rightPanelWidth = int(width * 0.25) self.rightPanel.setFixedWidth(rightPanelWidth) super().resizeEvent(event) if __name__ == "__main__": app = QApplication(sys.argv) mainWindow = MainContentComponent( robotPanel={"arg1": "value1"}, statusPanel={"arg1": "value1"} ) mainWindow.show() sys.exit(app.exec_())