peng3d.gui.container - GUI Container and Scrolling system

class peng3d.gui.container.Container(name, submenu, window, peng, pos=None, size=None, _skip_draw=False, font=None, font_size=None, font_color=None, borderstyle=None)[source]

Main class of the container system.

This widget may contain other widgets, limiting the childs to only draw within the defined bounds. Additionally, the given position will also act as a offset, making the child coordinates relative to the parent.

The visible attribute may be set to control whether or not this container is visible.

This Class is a subclass of peng3d.gui.widgets.Widget but also exhibits part of the API of peng3d.gui.SubMenu.

addWidget(widget, order_key=0)[source]

Adds a widget to this container.

Note that trying to add the Container to itself will be ignored.

clickable

Property used for determining if the widget should be clickable by the user.

This is only true if the submenu of this widget is active and this widget is enabled.

The widget may be either disabled by setting this property or the enabled attribute.

draw()[source]

Draws the submenu and its background.

Note that this leaves the OpenGL state set to 2d drawing and may modify the scissor settings.

getWidget(name)[source]

Returns the widget with the given name.

on_enter(old)[source]

Dummy method defined for compatibility with peng3d.gui.SubMenu, simply does nothing.

on_exit(new)[source]

Dummy method defined for compatibility with peng3d.gui.SubMenu, simply does nothing.

on_redraw()[source]

Redraws the background and any child widgets.

redraw()[source]

Triggers a redraw of the widget.

Note that the redraw may not be executed instantly, but rather batched together on the next frame. If an instant and synchronous redraw is needed, use on_redraw() instead.

setBackground(bg)[source]

Sets the background of the Container.

Similar to peng3d.gui.SubMenu.setBackground(), but only effects the region covered by the Container.

class peng3d.gui.container.ScrollableContainer(name, submenu, window, peng, pos=None, size=None, scrollbar_width=12, font=None, font_size=None, font_color=None, borderstyle=None, content_height=100)[source]

Subclass of Container allowing for scrolling its content.

The scrollbar currently is always on the right side and simply consists of a peng3d.gui.slider.VerticalSlider.

scrollbar_width and borderstyle will be passed to the scrollbar.

content_height refers to the maximum offset the user can scroll to.

The content height may be changed, but manually calling redraw() will be necessary.

on_redraw()[source]

Redraws the background and contents, including scrollbar.

This method will also check the scrollbar for any movement and will be automatically called on movement of the slider.

class peng3d.gui.container.ContainerButtonBackground(widget, border=[4, 4], borderstyle='flat', batch=None, change_on_press=None)[source]

Background class used to render the background of containers using a button style.

Mostly identical with ButtonBackground with added compatibility for containers.

getColors()[source]

Overrideable function that generates the colors to be used by various borderstyles.

Should return a 5-tuple of (bg,o,i,s,h).

bg is the base color of the background.

o is the outer color, it is usually the same as the background color.

i is the inner color, it is usually lighter than the background color.

s is the shadow color, it is usually quite a bit darker than the background.

h is the highlight color, it is usually quite a bit lighter than the background.