glydget

Widget

class Widget

Bases: object

The Widget class is the base class for all glydget widgets. It provides the common set of method for the widgets including:

  • selection methods
  • methods to hide and and show widgets
  • methods to manage size allocation and requests
  • methods to deal with the widget’s place in the widget hierarchy
  • event management methods
  • methods to modify the style settings

Widget introduces style properties - these are basically object properties that are stored not on the object, but in the style object associated to the widget.

Known sub-classes:

Methods

Widget.show([batch, group]) Show widget on screen.
Widget.hide() Hide widget.
Widget.move(x, y) Move widget to (x,y).
Widget.resize(width, height) Resize widget to (width, height).
Widget.activate() Activate widget.
Widget.deactivate() Deactivate widget.
Widget.focus() Focus widget.
Widget.unfocus() Unfocus widget.

Properties

Widget.state Widget current state.
Widget.style Style associated to the widget.
Widget.size_request Widget size request
Widget.focusable Indicate whether widget can be focused.
Widget.activable Indicate whether widget can be activated.
Widget.focused Indicate whether widget is currently focused.
Widget.activated Indicate whether widget is currently activated.
Widget.expand Widget propension to expand itself when possible.
Widget.x X coordinate of top-left corner.
Widget.y Y coordinate of top-left corner.
Widget.width Width in pixels.
Widget.height Height in pixels.
Widget.parent Parent container or None if the widget has no parent.
Widget.root Toplevel container or self if the widget has no parent.
Widget.batch Graphic batch where widget is currently in.
Widget.group Graphic group this widget belongs to.

Methods Details

Widget.show(batch=None, group=None)

Show widget on screen.

Parameters:
batch : pyglet.graphics.Batch
Optional batch to add the object to
group : pyglet.graphics.Group
Optional group to use
Widget.hide()
Hide widget.
Widget.move(x, y)

Move widget to (x,y).

If widget is a toplevel widget, the move method actually moves the widget to the specified location. If widget is not a toplevel widget, the move method will move the whole hierarchy to a new location that will result in this widget being at the specified location.

Parameters:
x : int

X coordinate of widget top-left corner

y : int

Y coordinate of widget top-left corner

Widget.resize(width, height)

Resize widget to (width, height).

Parameters:
width : int

Width of the object in pixels

height : int

Height of the object in pixels

Widget.activate()
Activate widget.
Widget.deactivate()
Deactivate widget.
Widget.focus()
Focus widget.
Widget.unfocus()
Unfocus widget.

Properties Details

Widget.state

Widget current state.

One of:
  • glydget.state.default : default widget state.
  • glydget.state.activated : widget receives keyboard and mouse events.
  • glydget.state.focused : widget receives mouse events.
  • glydget.state.selected : widget has been selected.
  • glydget.state.insensitive : widget cannot be activated, selected or focused.
Widget.style

Style associated to the widget.

Type:glydget.style.Style, read-write.
Widget.size_request
Widget size request
Widget.focusable

Indicate whether widget can be focused.

Type:bool, read-write.
Widget.activable

Indicate whether widget can be activated.

Type:bool, read-write.
Widget.focused

Indicate whether widget is currently focused.

Type:bool, read-only.
Widget.activated

Indicate whether widget is currently activated.

Type:bool, read-only.
Widget.expand

Widget propension to expand itself when possible.

Type:[bool,bool] read-write.
Widget.x

X coordinate of top-left corner.

Type:int, read-only.
Widget.y

Y coordinate of top-left corner.

Type:int, read-only.
Widget.width

Width in pixels.

Type:int, read-only.
Widget.height

Height in pixels.

Type:int, read-only.
Widget.parent

Parent container or None if the widget has no parent.

Type:glydget.widget.Widget, read-only.
Widget.root

Toplevel container or self if the widget has no parent.

Type:glydget.widget.Widget, read-only.
Widget.batch

Graphic batch where widget is currently in.

Type:pyglet.graphics.Batch, read-only.
Widget.group

Graphic group this widget belongs to.

Type:pyglet.graphics.Group, read-only.