VirtualWidget#

class VirtualWidget#

Represents a virtual UI widget.

This class provides an abstraction for a UI widget, supporting properties such as text, coordinates, dimensions, visibility, focus state, and parent/child relationships.

__repr__() str#
__str__() str#
add_child(child) None#

Add a child widget to this widget.

Note: This does not automatically set the child widget’s parent. To preserve tree structure, you should also call set_parent() on the child widget to assign this widget as its parent.

Parameters:

child – Child widget.

get_child(index) VirtualWidget#

Get the child widget at the given index (starting from 0).

Throws an out_of_range exception if there are not that many children.

Parameters:

index – Index of the child widget.

Returns:

Child widget at the given index.

get_children() list[VirtualWidget]#

Get all children of this widget in the tree.

Returns:

List of all children widgets.

get_height() int#

Get the height of the current widget.

Returns:

Height of the widget.

get_help_text() str#

Get help text.

Help text is generally the secondary text content in a widget. When you hover the cursor over widgets, if a tooltip pops up, the tooltip content will be considered a help text.

Returns:

Help text.

get_native_name() str#

Get name of the native widget this virtual widget is mapped from.

Returns:

Native widget name.

get_parent() VirtualWidget#

Get the parent widget of the current widget.

Returns:

Parent widget.

get_title_text() str#

Get title text.

Title text is a string that represents the primary text content of the widget. - It can be the content string on the button, which says “Click me” - It can be the string that a text input is displaying (if any)

Returns:

Title text string.

get_widget_name() str#

Get the name of the current virtual widget in UpperCamelCase.

Examples: “VirtualButtonWidget”, “VirtualTextWidget”, etc.

Returns:

Current virtual widget name.

get_width() int#

Get the width of the current widget.

Returns:

Width of the widget.

get_x() int#

Get the X coordinate of the top-left corner of the widget relative to the screen.

The top-left corner of the screen is considered the origin.

Returns:

X coordinate.

get_y() int#

Get the Y coordinate of the top-left corner of the widget relative to the screen.

The top-left corner of the screen is considered the origin.

Returns:

Y coordinate.

is_focused() bool#

Get whether the current widget is focused.

Returns:

True if focused, False otherwise.

is_visible() bool#

Get whether the current widget is visible to the user.

Returns:

True if visible, False otherwise.

set_focused(focused) None#

Set whether the current widget is focused.

Parameters:

focused – True if focused, False otherwise.

set_height(height) None#

Set the height of the current widget.

Parameters:

height – Height of the widget.

set_help_text(help_text) None#

Set help text.

See also: get_help_text()

Parameters:

help_text – Help text string.

set_native_name(native_name) None#

Set native widget name.

See also: get_native_name()

Parameters:

native_name – Name of the native widget this virtual widget is mapped from.

set_parent(parent) None#

Set the parent widget of the current widget.

Parameters:

parent – Parent widget.

set_title_text(title_text) None#

Set title text.

See also: get_title_text()

Parameters:

title_text – Title text string.

set_visible(visible) None#

Set whether the current widget is visible to the user.

Parameters:

visible – True if visible, False otherwise.

set_width(width) None#

Set the width of the current widget.

Parameters:

width – Width of the widget.

set_x(x_coord) None#

Set the X coordinate of the top-left corner of the widget.

Parameters:

x_coord – X coordinate.

set_y(y_coord) None#

Set the Y coordinate of the top-left corner of the widget.

Parameters:

y_coord – Y coordinate.