Changing WindowProperties at run-time?

wp = WindowProperties()

I can’t seem to change the resizability property of the window during run-time. Is this normal, or a bug? Where is this documented? Are there any work arounds?

That’s a limitation in the oeperating system. You need to set this before a window is opened, or open a new window.

Opening a new window seems fine, so long as it isn’t done too often. Thanks.

On a related note… Is it possible to lock the window’s (not the view) aspect ratio in Panda while allowing the user to resize?

Or should I just stick with the obvious alternative and correct the aspect ratio by resizing one of the window’s dimensions when a resize event fires?

This is not handled automatically in Panda. It might be possible to implement it as you describe.


i did that once, this may help you:

from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import  *

def setResolution( resolution ):
    wp = WindowProperties()
    # set resolution
    wp.setSize(resolution[0], resolution[1])
    # set fullscreen

class windowHandlerClass( DirectObject ):
  def __init__( self ): = True
    DirectObject.__init__( self )
    self.aspectRatio = [16., 9.] True ), 1, 1, 1))
    self.cameras = [, base.cam2d, base.cam2dp]
      self.accept( 'window-event', self.onResize)
  def onResize( self, window=None ):
    print "onResize"
    if window is None:
      window =
    wp = window.getProperties()
    winx = float(wp.getXSize())
    winy = float(wp.getYSize())
    drx = winy/float(self.aspectRatio[1])*float(self.aspectRatio[0])/winx
    dry = winx/float(self.aspectRatio[0])*float(self.aspectRatio[1])/winy
    dx = (1.-drx) / 2
    dy = (1.-dry) / 2.
    dim = dx , (1.-dx), dy, (1.-dy)
    reqx = round(winx*drx)
    reqy = round(winy*dry)
    reqx = winx
    reqy = round( winx/float(self.aspectRatio[0])*float(self.aspectRatio[1]) )
    if winx != reqx or winy != reqy:
      print winx, winy, reqx, reqy, reqx/float(reqy)
      setResolution( [reqx, reqy] )

if __name__ == '__main__':
  from direct.directbase import DirectStart
  windowHandler = windowHandlerClass()

I actually got it done this morning and forgot to post here, but I appreciate the help anyway.