peng3d.gui - 2D Widget based GUI System¶
-
class
peng3d.gui.GUIMenu(name, window, peng, font='Arial', font_size=16, font_color=[62, 67, 73, 255], borderstyle='flat')[source]¶ peng3d.menu.Menusubclass adding 2D GUI Support.Note that widgets are not managed directly by this class, but rather by each
SubMenu.-
addSubMenu(submenu)[source]¶ Adds a
SubMenuto this Menu.Note that nothing will be displayed unless a submenu is activated.
-
changeSubMenu(submenu)[source]¶ Changes the submenu that is displayed.
Raises: ValueError – if the name was not previously registered
-
draw()[source]¶ Draws each menu layer and the active submenu.
Note that the layers are drawn first and may be overridden by the submenu and widgets.
-
on_enter(old)[source]¶ Same as
BasicMenu.on_enter(), but also callsLayer.on_menu_enter()on every layer.
Property containing the
SubMenuinstance that is currently active.
-
-
class
peng3d.gui.SubMenu(name, menu, window, peng, font=None, font_size=None, font_color=None, borderstyle=None)[source]¶ Sub Menu of the GUI system.
Each instance must be registered with their menu to work properly, see
GUIMenu.addSubMenu().Actions supported by default:
enteris triggered everytime theon_enter()method has been called.exitis triggered everytime theon_exit()method has been called.send_formis triggered if the contained form is sent by either pressing enter or callingsend_form().-
addWidget(widget, order_key=0)[source]¶ Adds a widget to this submenu.
order_keyoptionally specifies the “layer” this widget will be on. Note that this does not work with batched widgets. All batched widgets will be drawn before widgets that use a custom draw() method.
-
delWidget(widget)[source]¶ Deletes the widget by the given name.
Note that this feature is currently experimental as there seems to be a memory leak with this method.
-
draw()[source]¶ Draws the submenu and its background.
Note that this leaves the OpenGL state set to 2d drawing.
-
form_valid(ctx=None)[source]¶ Called to pre-check if a form is valid.
Should be overridden by subclasses.
By default, this always returns true.
Parameters: ctx – Arbitrary context Returns: If the form is valid
-
send_form(ctx=None)[source]¶ Triggers whatever form data is entered to be sent.
Only causes action
send_formto be sent if submenu is active andform_valid()returns true.The given context is stored in
form_ctx.Parameters: ctx – Arbitrary context Returns: If the form was actually sent
-
setBackground(bg)[source]¶ Sets the background of the submenu.
The background may be a RGB or RGBA color to fill the background with.
Alternatively, a
peng3d.layer.Layerinstance or other object with a.draw()method may be supplied. It is also possible to supply any other method or function that will get called.Also, the strings
flat,gradient,oldshadowandmaterialmay be given, resulting in a background that looks similar to buttons.If the Background is
None, the default background of the parent menu will be used.Lastly, the string
"blank"may be passed to skip background drawing.
-