Skip to content

GUI Widget

GuiWidget

GuiWidget(
    title_and_content: Any | tuple[Any, ...],
    content: Any | tuple[Any, ...] | None = None,
    *,
    color: str | tuple[int, int, int] | None = None,
    value: str | int | bool | None = None,
    select: int | str | None = None,
    toggle_state: bool | None = None,
    range: tuple[int, int] | None = None
)

Bases: Input

GUI windows widget which also acts like an input port

Parameters:

  • title (Any) –

    Widget's title

  • content (Any | tuple[Any, ...] | None, default: None ) –

    Widget's text or text for its items

  • color (str | tuple[int, int, int] | None, default: None ) –

    Color as color name or RGB tuple

  • value (str | int | bool | None, default: None ) –

    Initial value

  • select (int | str | None, default: None ) –

    Preselected item

  • toggle_state (bool | None, default: None ) –

    Initial toggle state

is_enabled

is_enabled: bool

True if port is listening and generating messages

calls

calls: list[None | tuple[tuple, dict], list[SubscribedCall]]

Message match arguments and callables that will be called with matching incoming messages. None conditions matches any message.

title

title = str(title_and_content)

Widget's title

qt_widget

qt_widget: QWidget

Wrapped PySide6 QWidget that can be altered for extra customization

content

content: Any | tuple[Any, ...]

Widget's text or text for its items

value

value: str | int | bool | None

Widget's value / selected item text

selected_item_text

selected_item_text: str | None

Widget's currently selected item's text

selected_item_index

selected_item_index: int | None

Widget's currently selected item's index

toggle_state

toggle_state: bool | None

Toggle state

range

range: tuple[int, int] | None

Value range

color

color: str | tuple[int, int, int] | None

Color as color name or RGB tuple

is_visible

is_visible: bool

Widget is currently visible

select

select(selection: int | str) -> None

Select widget's item

Parameters:

  • selection (int | str) –

    Index or text of item to select

subscribe

subscribe(call: Callable[[GuiEventMsg], None]) -> Callable
subscribe(
    type: None | Container[GuiEvent] | GuiEvent = None,
    data: None | Container | str | int | bool | Sequence = None,
) -> Callable
subscribe(
    type: None | Container[GuiEvent] | GuiEvent = None,
    data: None | Container | str | int | bool | Sequence = None,
) -> Callable

Decorator to subscribe a callable to the input's messages.

Decorator without arguments subscribes a callable to all the input's messages.

Decorator with arguments subscribes a callable to the input's messages that match conditions set by arguments. It works the same way as message's matches method:

  1. If condition is None or omitted it matches anything.

  2. If condition equals attribute it matches the attribute.

  3. If condition is a container and contains the attribute it matches the attribute.

Examples
  1. Calls function for all MIDI port's messages:
    @midi_input_instance.subscribe
    def function(msg: MidiMsg) -> None:
        pass
    
  2. Calls function for OSC messages from specific address:
    @osc_input_instance.subscribe(address='/live/song/get/track_data')
    def function(msg: OscMsg) -> None:
        pass
    
  3. Call object instance method for MIDI port's "note on" and "note off" messages:
    midi_input_instance.subscribe((MidiType.NOTE_ON, MidiType.NOTE_OFF))(object.method)
    

Returns:

  • Callable

    Subscribed callable.