Skip to content

1.1 DirectAutoSizer

Fireclaw edited this page Dec 29, 2020 · 3 revisions

The auto sizer will enlarge the frameSize of a widget to the size (frameSize or bounds) of the given parent item. This can currently be either a gui widget or NodePath.

Example

from direct.gui.DirectFrame import DirectFrame
from DirectGuiExtension.DirectAutoSizer import DirectAutoSizer

myFrame = DirectFrame()

# stretch myFrame to the windows bounds
DirectAutoSizer(child=myFrame)

options

extendHorizontal: Boolean
Determines if the sizer should extend on the horizontal or keep the frameSize in this direction.

extendVertical: Boolean
Determines if the sizer should extend on the vertical or keep the frameSize in this direction.

minSize: Tuple of 4 or LVecBase4f
The minimum size the sizer should be able to scale to.

maxSize: None, Tuple of 4 or LVecBase4f
The maximum size the sizer should be able to scale to. If None, the sizer can grow indefinitely.

updateOnWindowResize: Boolean
If set to True, the sizer will be resized when the window is resized. This should be enabled if the sizer is parented to None or the default gui parent to keep it at the same size of the window even if the aspect ratio changes.

childUpdateSizeFunc: Function pointer
A function that will be called whenever the sizers' size gets changed. This usually will be a function of the child element to refresh it accordingly. Some of the widgets provided by this extension, like the DirectBoxSizer, should pass their refresh function to update correctly.
E.g.:

   DirectAutoSizer(child=myBoxSizer, childUpdateSizeFunc=myBoxSizer.refresh)

Clone this wiki locally