from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy from Gui import Ui_fluencyCAD # Import the generated GUI module from modules.gl_widget import OpenGLWidget class MainWindow(QMainWindow): def __init__(self): super().__init__() # Set up the UI from the generated GUI module self.ui = Ui_fluencyCAD() self.ui.setupUi(self) self.openGLWidget = OpenGLWidget() self.openGLWidget.setParent(self.ui.gl_canvas) # Connect the resizeEvent of the parent widget to a function self.ui.gl_canvas.resizeEvent = self.glCanvasResized def glCanvasResized(self, event): # Get the size of the gl_canvas canvas_size = self.ui.gl_canvas.size() # Resize the OpenGL widget to match the size of the gl_canvas self.openGLWidget.resize(canvas_size) if __name__ == "__main__": app = QApplication([]) window = MainWindow() window.show() app.exec()