batgrl.gadgets.menu#
A menu and menu bar gadget.
Functions
|
Return the number of arguments of callable. |
Classes
|
A menu gadget. |
|
A menu bar. |
|
|
|
- class batgrl.gadgets.menu.Menu(close_on_release: bool = True, close_on_click: bool = True, alpha: float = 1.0, orientation='tb-lr', grid_rows: int = 1, grid_columns: int = 1, padding_left: int = 0, padding_right: int = 0, padding_top: int = 0, padding_bottom: int = 0, horizontal_spacing: int = 0, vertical_spacing: int = 0, size: Size = (10, 10), pos: Point = (0, 0), size_hint: SizeHint | None = None, pos_hint: PosHint | None = None, is_transparent: bool = False, is_visible: bool = True, is_enabled: bool = True)#
Bases:
GridLayout
A menu gadget.
Menus are constructed with the class method
from_dict_of_dicts()
. Each key of the dict should be a tuple of two strings for left and right labels and each value should be either a callable with no arguments for a normal menu item, a callable with one argument for a toggle menu item (the argument will be the toggle state of the menu item), or a dict (for a submenu).Once opened, a menu can be navigated with the mouse or arrow keys.
- Parameters:
- close_on_releasebool, default: True
Whether to close the menu when an item is selected.
- close_on_clickbool, default: True
Whether to close the menu when a click doesn’t collide with it.
- alphafloat, default: 1.0
Transparency of gadget.
- grid_rowsint, default: 1
Number of rows.
- grid_columnsint, default: 1
Number of columns.
- orientationOrientation, default: “tb-lr”
The orientation of the grid.
- padding_leftint, default: 0
Padding on left side of grid.
- padding_rightint, default: 0
Padding on right side of grid.
- padding_topint, default: 0
Padding at the top of grid.
- padding_bottomint, default: 0
Padding at the bottom of grid.
- horizontal_spacingint, default: 0
Horizontal spacing between children.
- vertical_spacingint, default: 0
Vertical spacing between children.
- sizeSize, default: Size(10, 10)
Size of gadget.
- posPoint, default: Point(0, 0)
Position of upper-left corner in parent.
- size_hintSizeHint | None, default: None
Size as a proportion of parent’s height and width.
- pos_hintPosHint | None, default: None
Position as a proportion of parent’s height and width.
- is_transparentbool, default: False
Whether gadget is transparent.
- is_visiblebool, default: True
Whether gadget is visible. Gadget will still receive input events if not visible.
- is_enabledbool, default: True
Whether gadget is enabled. A disabled gadget is not painted and doesn’t receive input events.
- Attributes:
- close_on_releasebool
Whether to close the menu when an item is selected.
- close_on_clickbool
Whether to close the menu when a click doesn’t collide with it.
alpha
floatTransparency of gadget.
min_grid_size
SizeReturn the minimum grid size to show all children.
- grid_rowsint
Number of rows.
- grid_columnsint
Number of columns.
orientation
OrientationThe orientation of the grid.
- padding_leftint
Padding on left side of grid.
- padding_rightint
Padding on right side of grid.
- padding_topint
Padding at the top of grid.
- padding_bottomint
Padding at the bottom of grid.
- horizontal_spacingint
Horizontal spacing between children.
- vertical_spacingint
Vertical spacing between children.
size
SizeSize of gadget.
height
intHeight of gadget.
rows
intHeight of gadget.
width
intWidth of gadget.
columns
intWidth of gadget.
pos
PointPosition relative to parent.
top
inty-coordinate of top of gadget.
y
inty-coordinate of top of gadget.
left
intx-coordinate of left side of gadget.
x
intx-coordinate of left side of gadget.
bottom
inty-coordinate of bottom of gadget.
right
intx-coordinate of right side of gadget.
center
PointPosition of center of gadget.
absolute_pos
PointAbsolute position on screen.
size_hint
SizeHintGadget’s size as a proportion of its parent’s size.
pos_hint
PosHintGadget’s position as a proportion of its parent’s size.
- parent: Gadget | None
Parent gadget.
- childrenlist[Gadget]
Children gadgets.
is_transparent
boolWhether gadget is transparent.
is_visible
boolWhether gadget is visible.
is_enabled
boolWhether gadget is enabled.
root
Gadget | NoneReturn the root gadget if connected to gadget tree.
app
AppThe running app.
Methods
open_menu()
Open menu.
close_menu()
Close menu.
from_dict_of_dicts(…)
Constructor to create a menu from a dict of dicts. This should be default way of constructing menus.
index_at(row, col)
Return index of gadget in
children
at position row, col in the grid.apply_hints()
Apply size and pos hints.
to_local(point)
Convert point in absolute coordinates to local coordinates.
collides_point(point)
Return true if point collides with visible portion of gadget.
collides_gadget(other)
Return true if other is within gadget’s bounding box.
pull_to_front()
Move to end of gadget stack so gadget is drawn last.
walk()
Yield all descendents of this gadget (preorder traversal).
walk_reverse()
Yield all descendents of this gadget (reverse postorder traversal).
ancestors()
Yield all ancestors of this gadget.
add_gadget(gadget)
Add a child gadget.
add_gadgets(*gadgets)
Add multiple child gadgets.
remove_gadget(gadget)
Remove a child gadget.
prolicide()
Recursively remove all children.
destroy()
Remove this gadget and recursively remove all its children.
bind(prop, callback)
Bind callback to a gadget property.
unbind(uid)
Unbind a callback from a gadget property.
tween(…)
Sequentially update gadget properties over time.
on_size()
Update gadget after a resize.
on_transparency()
Update gadget after transparency is enabled/disabled.
on_add()
Update gadget after being added to the gadget tree.
on_remove()
Update gadget after being removed from the gadget tree.
on_key(key_event)
Handle a key press event.
on_mouse(mouse_event)
Handle a mouse event.
on_paste(paste_event)
Handle a paste event.
on_terminal_focus(focus_event)
Handle a focus event.
- add_gadget(gadget)#
Check to see if grid is full before adding gadget and remove its hints.
- add_gadgets(*gadgets: Self) → None#
Add multiple child gadgets.
- Parameters:
- *gadgetsGadget
Gadgets to add as children. Can also accept a single iterable of gadgets.
- property alpha: float#
Transparency of gadget.
- ancestors() → Iterator[Self]#
Yield all ancestors of this gadget.
- Yields:
- Gadget
An ancestor of this gadget.
- property app#
The running app.
- apply_hints() → None#
Apply size and pos hints.
This is called automatically when the gadget is added to the gadget tree and when the gadget’s parent’s size changes.
- bind(prop: str, callback: Callable[[], None]) → int#
Bind callback to a gadget property. When the property is updated, callback is called with no arguments.
- Parameters:
- propstr
The name of the gadget property.
- callbackCallable[[], None]
Callback to bind to property.
- Returns:
- int
A unique id used to unbind the callback.
- property bottom: int#
y-coordinate of bottom of gadget.
- children: _GadgetList#
The gadget’s children.
- close_menu()#
Close the menu.
- close_parents()#
Close all parent menus.
- close_submenus()#
Close all submenus.
- collides_gadget(other: Self) → bool#
Return true if other is within gadget’s bounding box.
- Parameters:
- otherGadget
Another gadget.
- Returns:
- bool
Whether other collides with gadget.
- collides_point(point: Point) → bool#
Return true if point collides with visible portion of gadget.
- Parameters:
- pointPoint
A point.
- Returns:
- bool
Whether point collides with gadget.
- property columns: int#
Width of gadget.
- destroy() → None#
Remove this gadget and recursively remove all its children.
- dispatch_key(key_event: KeyEvent) → bool | None#
Dispatch a key press event until handled.
A key press event is handled if a handler returns
True
.- Parameters:
- key_eventKeyEvent
The key event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_mouse(mouse_event: MouseEvent) → bool | None#
Dispatch a mouse event until handled.
A mouse event is handled if a handler returns
True
.- Parameters:
- mouse_eventMouseEvent
The mouse event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_paste(paste_event: PasteEvent) → bool | None#
Dispatch a paste event until handled.
A paste event is handled if a handler returns
True
.- Parameters:
- paste_eventPasteEvent
The paste event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_terminal_focus(focus_event: FocusEvent) → bool | None#
Dispatch a focus event until handled.
A focus event is handled if a handler returns
True
.- Parameters:
- focus_eventFocusEvent
The focus event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- classmethod from_dict_of_dicts(menu: MenuDict, pos: Point = (0, 0), close_on_release: bool = True, close_on_click: bool = True, alpha: float = 1.0) → Iterator[Self]#
Create and yield menus from a dict of dicts. Callables should either have no arguments for a normal menu item, or one argument for a toggle menu item.
- Parameters:
- menuMenuDict
The menu as a dict of dicts.
- posPoint, default: Point(0, 0)
Position of menu.
- close_on_releasebool, default: True
Whether to close the menu when an item is selected.
- close_on_clickbool, default: True
Whether to close the menu when a click doesn’t collide with it.
- alphafloat, default: 1.0
Transparency of gadget.
- Yields:
- Menu
The menu or one of its submenus.
- grid_columns: int#
- grid_rows: int#
- property height: int#
Height of gadget.
- horizontal_spacing: int#
- index_at(row: int, col: int) → int#
Return the index of the child gadget in
children
at a given row and column in the grid.- Parameters:
- rowint
The row of the child.
- colint
The column of the child.
- Returns:
- int
Index of the child in
children
.
- property is_enabled: bool#
Whether gadget is enabled. A disabled gadget is not painted and doesn’t receive input events.
- property is_transparent: bool#
Whether gadget is transparent.
- property is_visible: bool#
Whether gadget is visible. Gadget will still receive input events if not visible.
- property left: int#
x-coordinate of left side of gadget.
- on_add() → None#
Update gadget after being added to the gadget tree.
- on_key(key_event)#
Navigate menus with arrow keys and select menu items with enter.
- on_mouse(mouse_event)#
Close menus on non-colliding mouse down.
- on_paste(paste_event: PasteEvent) → bool | None#
Handle a paste event.
Handled paste events should return
True
.- Parameters:
- paste_eventPasteEvent
The paste event to handle.
- Returns:
- bool | None
Whether the paste event was handled.
- on_remove() → None#
Update gadget after being removed from the gadget tree.
- on_size()#
Repositon children on resize.
- on_terminal_focus(focus_event: FocusEvent) → bool | None#
Handle a focus event.
Handled focus events should return
True
.- Parameters:
- focus_eventFocusEvent
The focus event to handle.
- Returns:
- bool | None
Whether the focus event was handled.
- on_transparency() → None#
Update gadget after transparency is enabled/disabled.
- open_menu()#
Open the menu.
- property orientation: Literal['lr-tb', 'lr-bt', 'rl-tb', 'rl-bt', 'tb-lr', 'tb-rl', 'bt-lr', 'bt-rl']#
The orientation of the grid.
Describes how the grid fills as children are added. The default is left-to-right then top-to-bottom.
- padding_bottom: int#
- padding_left: int#
- padding_right: int#
- padding_top: int#
- prolicide() → None#
Recursively remove all children.
- pull_to_front() → None#
Move gadget to end of gadget stack so that it is drawn last.
- remove_gadget(gadget)#
Reposition children when a gadget is removed.
- property right: int#
x-coordinate of right side of gadget.
- property root: Self | None#
Return the root gadget if connected to gadget tree.
- property rows: int#
Height of gadget.
- to_local(point: Point) → Point#
Convert point in absolute coordinates to local coordinates.
- Parameters:
- pointPoint
Point in absolute (screen) coordinates.
- Returns:
- Point
The point in local coordinates.
- property top: int#
y-coordinate of top of gadget.
- async tween(*, duration: float = 1.0, easing: Literal['linear', 'in_quad', 'out_quad', 'in_out_quad', 'in_cubic', 'out_cubic', 'in_out_cubic', 'in_quart', 'out_quart', 'in_out_quart', 'in_quint', 'out_quint', 'in_out_quint', 'in_sine', 'out_sine', 'in_out_sine', 'in_exp', 'out_exp', 'in_out_exp', 'in_circ', 'out_circ', 'in_out_circ', 'in_elastic', 'out_elastic', 'in_out_elastic', 'in_back', 'out_back', 'in_out_back', 'in_bounce', 'out_bounce', 'in_out_bounce'] = 'linear', on_start: Callable[[], None] | None = None, on_progress: Callable[[float], None] | None = None, on_complete: Callable[[], None] | None = None, **properties: Real | ndarray[Any, dtype[number]] | Sequence[Real] | PosHint | SizeHint) → None#
Coroutine that sequentially updates gadget properties over a duration (in seconds).
- Parameters:
- durationfloat, default: 1.0
The duration of the tween in seconds.
- easingEasing, default: “linear”
The easing used for tweening.
- on_startCallable[[], None] | None, default: None
Called when tween starts.
- on_progressCallable[[float], None] | None, default: None
Called as tween updates with current progress.
- on_completeCallable[[], None] | None, default: None
Called when tween completes.
- **propertiesReal | NDArray[np.number] | Sequence[Real] | PosHint | SizeHint
Gadget properties’ target values. E.g., to smoothly tween a gadget’s position to (5, 10) over 2.5 seconds, specify the pos property as a keyword-argument:
await gadget.tween(pos=(5, 10), duration=2.5, easing="out_bounce")
Warning
Running several tweens on the same properties concurrently will probably result in unexpected behavior.
Notes
Tweened values will be coerced to match the type of the initial value of their corresponding property.
Non-numeric values will be set immediately.
- unbind(uid: int) → None#
Unbind a callback from a gadget property.
- Parameters:
- uidint
Unique id returned by the
bind()
method.
- vertical_spacing: int#
- walk() → Iterator[Self]#
Yield all descendents of this gadget (preorder traversal).
- Yields:
- Gadget
A descendent of this gadget.
- walk_reverse() → Iterator[Self]#
Yield all descendents of this gadget (reverse postorder traversal).
- Yields:
- Gadget
A descendent of this gadget.
- property width: int#
Width of gadget.
- property x: int#
x-coordinate of left side of gadget.
- property y: int#
y-coordinate of top of gadget.
- class batgrl.gadgets.menu.MenuBar(close_on_release: bool = True, close_on_click: bool = True, alpha: float = 1.0, orientation='tb-lr', grid_rows: int = 1, grid_columns: int = 1, padding_left: int = 0, padding_right: int = 0, padding_top: int = 0, padding_bottom: int = 0, horizontal_spacing: int = 0, vertical_spacing: int = 0, size: Size = (10, 10), pos: Point = (0, 0), size_hint: SizeHint | None = None, pos_hint: PosHint | None = None, is_transparent: bool = False, is_visible: bool = True, is_enabled: bool = True)#
Bases:
GridLayout
A menu bar.
A menu bar is constructed with the class method
from_iterable()
from an iterable of (str, MenuDict).- Parameters:
- close_on_releasebool, default: True
Whether to close the menu when an item is selected.
- close_on_clickbool, default: True
Whether to close the menu when a click doesn’t collide with it.
- alphafloat, default: 1.0
Transparency of gadget.
- grid_rowsint, default: 1
Number of rows.
- grid_columnsint, default: 1
Number of columns.
- orientationOrientation, default: “lr-bt”
The orientation of the grid.
- left_paddingint, default: 0
Padding on left side of grid.
- right_paddingint, default: 0
Padding on right side of grid.
- top_paddingint, default: 0
Padding at the top of grid.
- bottom_paddingint, default: 0
Padding at the bottom of grid.
- horizontal_spacingint, default: 0
Horizontal spacing between children.
- vertical_spacingint, default: 0
Vertical spacing between children.
- fg_colorColor | None, default: WHITE
Foreground color of gadget.
- bg_colorColor | None, default: BLACK
Background color of gadget.
- sizeSize, default: Size(10, 10)
Size of gadget.
- posPoint, default: Point(0, 0)
Position of upper-left corner in parent.
- size_hintSizeHint | None, default: None
Size as a proportion of parent’s height and width.
- pos_hintPosHint | None, default: None
Position as a proportion of parent’s height and width.
- is_transparentbool, default: False
Whether gadget is transparent.
- is_visiblebool, default: True
Whether gadget is visible. Gadget will still receive input events if not visible.
- is_enabledbool, default: True
Whether gadget is enabled. A disabled gadget is not painted and doesn’t receive input events.
- Attributes:
close_on_release
boolWhether to close the menu when an item is selected.
close_on_click
boolWhether to close the menu when a click doesn’t collide with it.
alpha
floatTransparancy of gadget.
- grid_rowsint
Number of rows.
- grid_columnsint
Number of columns.
orientation
OrientationThe orientation of the grid.
- left_paddingint
Padding on left side of grid.
- right_paddingint
Padding on right side of grid.
- top_paddingint
Padding at the top of grid.
- bottom_paddingint
Padding at the bottom of grid.
- horizontal_spacingint
Horizontal spacing between children.
- vertical_spacingint
Vertical spacing between children.
- fg_colorColor | None
Foreground color of gadget.
- bg_colorColor | None
Background color of gadget.
size
SizeSize of gadget.
height
intHeight of gadget.
rows
intHeight of gadget.
width
intWidth of gadget.
columns
intWidth of gadget.
pos
PointPosition relative to parent.
top
inty-coordinate of top of gadget.
y
inty-coordinate of top of gadget.
left
intx-coordinate of left side of gadget.
x
intx-coordinate of left side of gadget.
bottom
inty-coordinate of bottom of gadget.
right
intx-coordinate of right side of gadget.
center
PointPosition of center of gadget.
absolute_pos
PointAbsolute position on screen.
size_hint
SizeHintGadget’s size as a proportion of its parent’s size.
pos_hint
PosHintGadget’s position as a proportion of its parent’s size.
- parent: Gadget | None
Parent gadget.
- childrenlist[Gadget]
Children gadgets.
is_transparent
boolWhether gadget is transparent.
is_visible
boolWhether gadget is visible.
is_enabled
boolWhether gadget is enabled.
root
Gadget | NoneReturn the root gadget if connected to gadget tree.
app
AppThe running app.
Methods
open_menu()
Open menu.
close_menu()
Close menu.
from_dict_of_dicts(…)
Constructor to create a menu from a dict of dicts. This should be default way of constructing menus.
index_at(row, col)
Return index of gadget in
children
at position row, col in the grid.apply_hints()
Apply size and pos hints.
to_local(point)
Convert point in absolute coordinates to local coordinates.
collides_point(point)
Return true if point collides with visible portion of gadget.
collides_gadget(other)
Return true if other is within gadget’s bounding box.
pull_to_front()
Move to end of gadget stack so gadget is drawn last.
walk()
Yield all descendents of this gadget (preorder traversal).
walk_reverse()
Yield all descendents of this gadget (reverse postorder traversal).
ancestors()
Yield all ancestors of this gadget.
add_gadget(gadget)
Add a child gadget.
add_gadgets(*gadgets)
Add multiple child gadgets.
remove_gadget(gadget)
Remove a child gadget.
prolicide()
Recursively remove all children.
destroy()
Remove this gadget and recursively remove all its children.
bind(prop, callback)
Bind callback to a gadget property.
unbind(uid)
Unbind a callback from a gadget property.
tween(…)
Sequentially update gadget properties over time.
on_size()
Update gadget after a resize.
on_transparency()
Update gadget after transparency is enabled/disabled.
on_add()
Update gadget after being added to the gadget tree.
on_remove()
Update gadget after being removed from the gadget tree.
on_key(key_event)
Handle a key press event.
on_mouse(mouse_event)
Handle a mouse event.
on_paste(paste_event)
Handle a paste event.
on_terminal_focus(focus_event)
Handle a focus event.
- add_gadget(gadget)#
Check to see if grid is full before adding gadget and remove its hints.
- add_gadgets(*gadgets: Self) → None#
Add multiple child gadgets.
- Parameters:
- *gadgetsGadget
Gadgets to add as children. Can also accept a single iterable of gadgets.
- property alpha: float#
Transparancy of gadget.
- ancestors() → Iterator[Self]#
Yield all ancestors of this gadget.
- Yields:
- Gadget
An ancestor of this gadget.
- property app#
The running app.
- apply_hints() → None#
Apply size and pos hints.
This is called automatically when the gadget is added to the gadget tree and when the gadget’s parent’s size changes.
- bind(prop: str, callback: Callable[[], None]) → int#
Bind callback to a gadget property. When the property is updated, callback is called with no arguments.
- Parameters:
- propstr
The name of the gadget property.
- callbackCallable[[], None]
Callback to bind to property.
- Returns:
- int
A unique id used to unbind the callback.
- property bottom: int#
y-coordinate of bottom of gadget.
- children: _GadgetList#
The gadget’s children.
- property close_on_click: bool#
Whether to close the menu when a click doesn’t collide with it.
- property close_on_release: bool#
Whether to close the menu when an item is selected.
- collides_gadget(other: Self) → bool#
Return true if other is within gadget’s bounding box.
- Parameters:
- otherGadget
Another gadget.
- Returns:
- bool
Whether other collides with gadget.
- collides_point(point: Point) → bool#
Return true if point collides with visible portion of gadget.
- Parameters:
- pointPoint
A point.
- Returns:
- bool
Whether point collides with gadget.
- property columns: int#
Width of gadget.
- destroy() → None#
Remove this gadget and recursively remove all its children.
- dispatch_key(key_event: KeyEvent) → bool | None#
Dispatch a key press event until handled.
A key press event is handled if a handler returns
True
.- Parameters:
- key_eventKeyEvent
The key event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_mouse(mouse_event: MouseEvent) → bool | None#
Dispatch a mouse event until handled.
A mouse event is handled if a handler returns
True
.- Parameters:
- mouse_eventMouseEvent
The mouse event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_paste(paste_event: PasteEvent) → bool | None#
Dispatch a paste event until handled.
A paste event is handled if a handler returns
True
.- Parameters:
- paste_eventPasteEvent
The paste event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- dispatch_terminal_focus(focus_event: FocusEvent) → bool | None#
Dispatch a focus event until handled.
A focus event is handled if a handler returns
True
.- Parameters:
- focus_eventFocusEvent
The focus event to dispatch.
- Returns:
- bool | None
Whether the dispatch was handled.
- classmethod from_iterable(iter: Iterable[tuple[str, MenuDict]], pos: Point = (0, 0), close_on_release: bool = True, close_on_click: bool = True, alpha: float = 1.0) → Iterator[MenuBar | Menu]#
Create and yield a menu bar and menus from an iterable of tuple[str, MenuDict].
- Parameters:
- iterIterable[tuple[str, MenuDict]]
An iterable of tuple[str, MenuDict] from which to create the menu bar and menus.
- posPoint, default: Point(0, 0)
Position of menu.
- close_on_releasebool, default: True
Whether to close the menu when an item is selected.
- close_on_clickbool, default: True
Whether to close the menu when a click doesn’t collide with it.
- alphafloat, default: 1.0
Transparency of gadget.
- Yields:
- MenuBar | Menu
A menu or submenu of the menu bar or the menu bar.
- grid_columns: int#
- grid_rows: int#
- property height: int#
Height of gadget.
- horizontal_spacing: int#
- index_at(row: int, col: int) → int#
Return the index of the child gadget in
children
at a given row and column in the grid.- Parameters:
- rowint
The row of the child.
- colint
The column of the child.
- Returns:
- int
Index of the child in
children
.
- property is_enabled: bool#
Whether gadget is enabled. A disabled gadget is not painted and doesn’t receive input events.
- property is_transparent: bool#
Whether gadget is transparent.
- property is_visible: bool#
Whether gadget is visible. Gadget will still receive input events if not visible.
- property left: int#
x-coordinate of left side of gadget.
- on_add() → None#
Update gadget after being added to the gadget tree.
- on_mouse(mouse_event: MouseEvent) → bool | None#
Handle a mouse event.
Handled mouse events should return
True
.- Parameters:
- mouse_eventMouseEvent
The mouse event to handle.
- Returns:
- bool | None
Whether the mouse event was handled.
- on_paste(paste_event: PasteEvent) → bool | None#
Handle a paste event.
Handled paste events should return
True
.- Parameters:
- paste_eventPasteEvent
The paste event to handle.
- Returns:
- bool | None
Whether the paste event was handled.
- on_remove() → None#
Update gadget after being removed from the gadget tree.
- on_size()#
Repositon children on resize.
- on_terminal_focus(focus_event: FocusEvent) → bool | None#
Handle a focus event.
Handled focus events should return
True
.- Parameters:
- focus_eventFocusEvent
The focus event to handle.
- Returns:
- bool | None
Whether the focus event was handled.
- on_transparency() → None#
Update gadget after transparency is enabled/disabled.
- property orientation: Literal['lr-tb', 'lr-bt', 'rl-tb', 'rl-bt', 'tb-lr', 'tb-rl', 'bt-lr', 'bt-rl']#
The orientation of the grid.
Describes how the grid fills as children are added. The default is left-to-right then top-to-bottom.
- padding_bottom: int#
- padding_left: int#
- padding_right: int#
- padding_top: int#
- prolicide() → None#
Recursively remove all children.
- pull_to_front() → None#
Move gadget to end of gadget stack so that it is drawn last.
- remove_gadget(gadget)#
Reposition children when a gadget is removed.
- property right: int#
x-coordinate of right side of gadget.
- property root: Self | None#
Return the root gadget if connected to gadget tree.
- property rows: int#
Height of gadget.
- to_local(point: Point) → Point#
Convert point in absolute coordinates to local coordinates.
- Parameters:
- pointPoint
Point in absolute (screen) coordinates.
- Returns:
- Point
The point in local coordinates.
- property top: int#
y-coordinate of top of gadget.
- async tween(*, duration: float = 1.0, easing: Literal['linear', 'in_quad', 'out_quad', 'in_out_quad', 'in_cubic', 'out_cubic', 'in_out_cubic', 'in_quart', 'out_quart', 'in_out_quart', 'in_quint', 'out_quint', 'in_out_quint', 'in_sine', 'out_sine', 'in_out_sine', 'in_exp', 'out_exp', 'in_out_exp', 'in_circ', 'out_circ', 'in_out_circ', 'in_elastic', 'out_elastic', 'in_out_elastic', 'in_back', 'out_back', 'in_out_back', 'in_bounce', 'out_bounce', 'in_out_bounce'] = 'linear', on_start: Callable[[], None] | None = None, on_progress: Callable[[float], None] | None = None, on_complete: Callable[[], None] | None = None, **properties: Real | ndarray[Any, dtype[number]] | Sequence[Real] | PosHint | SizeHint) → None#
Coroutine that sequentially updates gadget properties over a duration (in seconds).
- Parameters:
- durationfloat, default: 1.0
The duration of the tween in seconds.
- easingEasing, default: “linear”
The easing used for tweening.
- on_startCallable[[], None] | None, default: None
Called when tween starts.
- on_progressCallable[[float], None] | None, default: None
Called as tween updates with current progress.
- on_completeCallable[[], None] | None, default: None
Called when tween completes.
- **propertiesReal | NDArray[np.number] | Sequence[Real] | PosHint | SizeHint
Gadget properties’ target values. E.g., to smoothly tween a gadget’s position to (5, 10) over 2.5 seconds, specify the pos property as a keyword-argument:
await gadget.tween(pos=(5, 10), duration=2.5, easing="out_bounce")
Warning
Running several tweens on the same properties concurrently will probably result in unexpected behavior.
Notes
Tweened values will be coerced to match the type of the initial value of their corresponding property.
Non-numeric values will be set immediately.
- unbind(uid: int) → None#
Unbind a callback from a gadget property.
- Parameters:
- uidint
Unique id returned by the
bind()
method.
- vertical_spacing: int#
- walk() → Iterator[Self]#
Yield all descendents of this gadget (preorder traversal).
- Yields:
- Gadget
A descendent of this gadget.
- walk_reverse() → Iterator[Self]#
Yield all descendents of this gadget (reverse postorder traversal).
- Yields:
- Gadget
A descendent of this gadget.
- property width: int#
Width of gadget.
- property x: int#
x-coordinate of left side of gadget.
- property y: int#
y-coordinate of top of gadget.
- batgrl.gadgets.menu.nargs(callable: Callable) → int#
Return the number of arguments of callable.