Bases: object
Base class of all GUI elements.
Parameters: |
|
---|
Parameter: | screen (pygame.Surface) – Surface to blit the widget on. |
---|
Overwrite this method and blit the widget, but call Widget.blit() there.
Return type: | pygame.Rect |
---|---|
Returns: | Dirty rect |
Get “image” from the style object and blit it centered.
Parameter: | point (Tuple) – A point (x, y) on the pygame screen. |
---|---|
Return type: | boolean |
Returns: | Whether the point touches the widget. By default, this simply uses self.rect.collidepoint. |
Overwrite this method to get more accurate mouse events for non-rectangular widgets.
Return type: | GUI |
---|---|
Returns: | the main GUI instance that contains this widget. |
Get the topmost GUI widget.
Parameter: | style_name (String) – Name of a requested style attribute. |
---|---|
Return type: | String |
Returns: | Style name suffix. |
Return a string that will be added to style_name before searching for the style attribute. See docs on Styling.
Parameter: | point (Tuple) – A point (x, y) on the pygame screen. |
---|---|
Return type: | Widget or False |
Returns: | Topmost widget at this point. |
Get the topmost widget at a certain point.
Parameter: | events (list) – pygame events that may be used |
---|---|
Return type: | list |
Returns: | pygame events that were not used |
Overwrite this method to process raw pygame events.
Parameters: |
|
---|
Add an event listener. See the event documentation.
Parameter: | offset (Tuple) – Offset between old and new position. This can have the same format like a normal position (eg. "40px", "20%", 80), but the values can be positive or negative. |
---|
Move the widget. This will not change the units of the current position.
Parameter: | anchor – anchor for the resize. Eg set it to "topright" if you want to move the bottomright corner. |
---|
Resize the widget. If amount is not possible, it will resize as far as possible.
Parameter: | pos (Tuple) – Absolute pixel position of the topleft widget corner with the topleft corner of the screen as point of origin. |
---|
Set the widgets topleft position. This won’t change the position unit. If the position is not reachable, the nearest possible position will be used.
Not yet implemented.
Todo
Implement Widget.set_size()
Parameters: |
|
---|
Remove a previously registered event handler. For more see the event documentation.
Parameter: | events (list) – pygame events that may be used |
---|---|
Return type: | list |
Returns: | pygame events that were not used |
Process events and update the widget.
Position of the widget. When setting, it is a pair of x and y coords relative to the parent layers topleft corner. Either absolute pixel values (eg. "30px") or relative to the parent size (eg. "50%"). When getting, it will be the absolute position on the pygame screen.
For more see the position documentation.
Size of the widget. When setting, it is a pair of width and height. Either absolute pixel values (eg "30px") or relative to the parent size (eg. "50%"). When getting, it will be the absolute width and hight.
For more see the size documentation.
Class name that will be used to get per-class styles (case insensitive). If it is None (which is the default), the class name will be used. This may be useful for inherited classes that should belong to the same style class group like their parent class. See Styling .. note:
Since this is a normal class attribute, this will be inherited
to all child classes. So only use when required.
Bases: gui.base.Widget
A Layer is a Widget that can contain other widgets (and Layers, since Layer is a child class of Widget). You can use Layers either as a frame, ie. to gorup different widgets, or to build own superwidgets, ie. widgets that contain other widgets. Child widgets cannot overlap a Layer, they must be completely contained.
The arguments are the same like for Widget. Only that size will be set to the size of the parent widget and pos to (0, 0) by default.
Parameters: |
|
---|
Add a Widget at the given index to the Layer.
Parameter: | screen (pygame.Surface) – Surface on which to blit. |
---|---|
Return type: | list |
Returns: | Rects that need to be updated (dirty rects). |
Blit the Layer and all its child Widgets, from background to foreground.
Parameters: |
|
---|
Change the index of a child Widget.
Parameter: | widget (Widget) – A child Widget of the Layer. |
---|---|
Return type: | int |
Returns: | Index of the given Widget. |
Parameter: | widget (Widget) – A child widget. |
---|---|
Return type: | pygame.Rect |
Returns: | The Inner Rects for the widget. |
Todo
document “borderwidth” standard syle attribute
Parameter: | point (Tuple) – A point (x, y) on the pygame screen. |
---|---|
Return type: | Widget or False |
Returns: | Topmost widget at this point. |
Get the topmost widget at a certain point.
Parameters: |
|
---|
Change the index of a child Widget relatively to its current index.
Parameters: |
|
---|
Remove a Widget from the Layer.
Parameter: | events (list) – Pygame events since the last frame that were not yet used |
---|---|
Returns: | list of events that were not used and can be passed to the next widget |
Update all children, from foreground to background, then the Layer itself.
Bases: gui.base.Layer
GUI is the topmost Layer and the only :class`Widget` that has no parent. Thus, you need a GUI before you can create other Widgets.
Parameters: |
|
---|
Parameter: | point (Tuple) – A point (x, y) on the pygame screen. |
---|---|
Return type: | Widget |
Returns: | Topmost widget at this point. |
Get the topmost widget at a certain point. This will always return a widget.
Tpye events: | list |
---|---|
Parameter: | events – Pygame events to process. |
Returns: | List of pygame events that were not used. |
Resize the GUI on pygame.VIDEORESIZE.