Skip to content

hkb_editor.gui.widgets.generic_input_widget

add_behavior_widget

add_behavior_widget(
    behavior: HavokBehavior,
    value_type: type,
    label: str,
    callback: Callable[[str, str | Any, Any], None],
    *,
    default: Any = None,
    choices: list[str | tuple[str | Any]] = None,
    readonly: bool = False,
    accept_on_enter: bool = False,
    flags_as_int: bool = False,
    parent: str = 0,
    tag: str = 0,
    user_data: Any = None,
    **kwargs,
) -> str

Create an input widget for any type appearing in a behavior.

Falls back to :func:add_generic_widget for the simple types, and adds pickers for Variable, Event, Animation and HkbRecord plus item tables for list and dict.

Parameters:

Name Type Description Default
behavior HavokBehavior

Behavior the pickers query for variables, events and animations.

required
value_type type

The type to create a widget for.

required
label str

Widget label.

required
callback callable

Called as callback(sender, value, user_data) on change.

required
See
required

add_generic_widget

add_generic_widget(
    value_type: type,
    label: str,
    callback: Callable[[str, str | Any, Any], None],
    *,
    default: Any = None,
    choices: list[str | tuple[str | Any]] = None,
    readonly: bool = False,
    flags_as_int: bool = False,
    accept_on_enter: bool = False,
    not_supported_ok: bool = False,
    parent: str = 0,
    tag: str = 0,
    user_data: Any = None,
    **kwargs,
) -> str

Create an input widget for any simple Python type.

Handles int, float, bool, str, Literal, Enum and Flag. Anything else raises ValueError unless not_supported_ok is set. See :func:add_behavior_widget for the behavior-aware types.

Parameters:

Name Type Description Default
value_type type

The type to create a widget for.

required
label str

Widget label.

required
callback callable

Called as callback(sender, value, user_data) on change.

required
default any

Initial value.

None
choices list

Turns the widget into a combo. Items may be (label, value) tuples.

None
readonly bool

Render the widget disabled.

False
flags_as_int bool

Render Flag types as a plain int input instead of checkboxes.

False
accept_on_enter bool

Only fire callback once Enter is pressed.

False
not_supported_ok bool

Return None instead of raising for unsupported types.

False
parent int or str

Container to add the widget to.

0
tag int or str

Explicit tag; auto-generated if 0.

0
user_data any

Passed through to callback.

None
Ko-fi donations