aspect ratio should be calculated like this:
ratio=float(1600)/1200
if canvas is not resized, you may need to call base.win.getDisplayRegions(), then adjust the size of each display region.
you should have the ‘reference’ documentation of Panda3d by you.
setAspectRatio method is in Lens class, while display region is another class. display region class should have a setDimension method.
also, if you use python, in interactive mode, you can type dir(base.camLens) to see what you can call on the Lens object. the same applies to any other python object.
Panda should automatically adjust the display regions and aspect ratio of a window that changes size. There should be no need for you to do it manually. Doing so may interfere with Panda’s mechanism.
If this is not the behaviour you’re seeing, there may be a bug in Panda. Which version of Panda are you using, and on which platform?
Note that Python sees your division as an integer division:
>>> 1200/1600
0
There should be no issues with changing the lens associated with base.cam, but there is also no reason to do so in your case, since Panda automatically adjusts the aspect ratio of whatever lens is stored in base.camLens.
I tried a couple of things including using OpenWindow for a new window.
Does setting the width and height of a new window through the WindowProperties. What I need to understand is how setting the size of a brand new window automatically sets its aspect ratio and if so, how can size of the canvas in that window (which I assume is based on the aspect ratio) be adjusted.
It might help for you to look in the ShowBase.py source code to see how this happens. ShowBase listens to “window-event”, and calls base.windowEvent(), which calls adjustWindowAspectRatio, which calls base.camLens.setAspectRatio.
This will not apply to a custom window opened by openWindow(), only to the default window.