@@ -52,9 +52,18 @@ def __init__(self):
5252 self .buffer_width = rect .width () * self .widget .devicePixelRatio ()
5353 self .buffer_height = rect .height () * self .widget .devicePixelRatio ()
5454
55- self .widget .setFixedSize (self .width , self .height )
55+ if self .resizable :
56+ size_policy = QtWidgets .QSizePolicy (
57+ QtWidgets .QSizePolicy .Expanding ,
58+ QtWidgets .QSizePolicy .Expanding ,
59+ )
60+ self .widget .setSizePolicy (size_policy )
61+ self .widget .resize (self .width , self .height )
62+ else :
63+ self .widget .setFixedSize (self .width , self .height )
5664
5765 self .widget .move (QtWidgets .QDesktopWidget ().rect ().center () - self .widget .rect ().center ())
66+ self .widget .resizeGL = self .resize # Needs to be set before show()
5867 self .widget .show ()
5968
6069 if not self .cursor :
@@ -70,7 +79,6 @@ def __init__(self):
7079 self .widget .keyPressEvent = self .keyPressEvent
7180 self .widget .keyReleaseEvent = self .keyReleaseEvent
7281 self .widget .mouseMoveEvent = self .mouseMoveEvent
73- self .widget .resizeGL = self .resizeGL
7482
7583 # Attach to the context
7684 self .ctx = moderngl .create_context (require = self .gl_version .code )
@@ -104,12 +112,21 @@ def mouseMoveEvent(self, event):
104112 """
105113 self .cursor_event (event .x (), event .y (), 0 , 0 )
106114
107- def resizeGL (self , width , height ):
115+ def resize (self , width , height ):
108116 """
109117 Pyqt specific resize callback.
110118 The window currently do not support resizing.
111119 """
112- print ("Resize" , width , height )
120+ if not self .fbo :
121+ return
122+
123+ self .width = width
124+ self .height = height
125+ self .buffer_width = self .width * self .widget .devicePixelRatio ()
126+ self .buffer_height = self .height * self .widget .devicePixelRatio ()
127+
128+ print (width , height )
129+ super ().resize (width , height )
113130
114131 def swap_buffers (self ):
115132 """
0 commit comments