widget¶
This module defines the following constants:
Widget options: * BGUI_DEFAULT = 0 * BGUI_CENTERX = 1 * BGUI_CENTERY = 2 * BGUI_NO_NORMALIZE = 4 * BGUI_NO_THEME = 8 * BGUI_NO_FOCUS = 16 * BGUI_CACHE = 32 * BGUI_CENTERED = BGUI_CENTERX | BGUI_CENTERY
Widget overflow: * BGUI_OVERFLOW_NONE = 0 * BGUI_OVERFLOW_HIDDEN = 1 * BGUI_OVERFLOW_REPLACE = 2 * BGUI_OVERFLOW_CALLBACK = 3
Mouse event states: * BGUI_MOUSE_NONE = 0 * BGUI_MOUSE_CLICK = 1 * BGUI_MOUSE_RELEASE = 2 * BGUI_MOUSE_ACTIVE = 4
Note
The Widget class should not be used directly in a gui, but should instead be subclassed to create other widgets.
- class bgui.widget.WeakMethod(f)¶
Bases:
object
- class bgui.widget.ArrayAnimation(widget, attrib, value, time_, callback)¶
Bases:
bgui.widget.Animation
- update()¶
- class bgui.widget.Widget(parent, name=None, aspect=None, size=[1, 1], pos=[0, 0], sub_theme='', options=0)¶
Bases:
object
The base widget class
- Parameters:
parent – The widget’s parent
name – The name of the widget
aspect – Constrain the widget size to a specified aspect ratio
size – A tuple containing the width and height
pos – A tuple containing the x and y position
sub_theme – Name of a sub_theme defined in the theme file (similar to CSS classes)
options – Various other options
- theme_section= 'Widget'
- theme_options= {}
- name= None
The widget’s name
- frozen= None
Whether or not the widget should accept events
- visible= None
Whether or not the widget is visible
- z_index= None
The widget’s z-index. Widget’s with a higher z-index are drawn over those that have a lower z-index
- on_click¶
The widget’s on_click callback
- on_release¶
The widget’s on_release callback
- on_hover¶
The widget’s on_hover callback
- on_mouse_enter¶
The widget’s on_mouse_enter callback
- on_mouse_exit¶
The widget’s on_mouse_exit callback
- on_active¶
The widget’s on_active callback
- parent¶
The widget’s parent
- system¶
A reference to the system object
- children¶
The widget’s children
- position¶
The widget’s position
- size¶
The widget’s size
- move(position, time, callback=None)¶
Move a widget to a new position over a number of frames.
- Parameters:
position – The new position
time – The time in milliseconds to take doing the move
callback – An optional callback that is called when he animation is complete
- add_animation(animation)¶
Add the animation to the list of currently running animations.
- Parameters:
animation – The animation