shellui.common package

shellui.common.debug module

shellui.common.debug.create_level(level: int, name: str)
shellui.common.debug.debug_start(logging_filename: str = 'shellui.log', logging_level: int = 7, logging_format: str = '%(asctime)s - %(levelname)s - %(filename)s : %(message)s\n', save_traceback: bool = True) None

shellui.common.interfaces module

class shellui.common.interfaces.AbstractLayoutInterface(*args, **kwargs)

Bases: BaseElementInterface, Protocol

add_elements(*args, **kwargs) BaseElementInterface | Collection
elements: Collection
search_elements_by_tag(tag: str) Collection
class shellui.common.interfaces.BaseElementInterface(*args, **kwargs)

Bases: Protocol

build() Buffer
deselect() None
event: EventManagerInterface
flags: FlagsManagerInterface
get_size() Position
keyboard: KeyboardManagerInterface
position: Position
render() str | List[Buffer]
select() None
set_fixed_size(size: Position | Tuple[int, int]) None
set_floating_size() None
size: Position
state: ElementState
tag: str
update() Any
class shellui.common.interfaces.CallInterface(*args, **kwargs)

Bases: Protocol

class shellui.common.interfaces.CreateInterface(cls: EventManagerInterface)

Bases: Protocol

cls: EventManagerInterface
class shellui.common.interfaces.EventManagerInterface(parent: object)

Bases: Protocol

call: CallInterface
call_event(event_name: str) Any
set: CreateInterface
set_events(*args, **kwargs)
class shellui.common.interfaces.FlagsManagerInterface(*args, **kwargs)

Bases: Protocol

flags: dict
parent: BaseElementInterface
class shellui.common.interfaces.KeyboardManagerInterface(*args, **kwargs)

Bases: Protocol

add_keyboard_event(function: ~typing.Callable, _lambda: ~typing.Callable = <function KeyboardManagerInterface.<lambda>>) KeyboardEvent
key_pressed(key_char) List[Any]
keyboard_events: List[KeyboardEvent]
parent: BaseElementInterface

shellui.common.types module

class shellui.common.types.Buffer(function: Callable[[], str | List[Self]] = None, position: Position = None, size: Size = None)

Bases: object

Represents a container for storing method and position used in text interface.

Parameters:
  • function (Callable[[], Union[str, List[Self]]]) – Function that returns text or buffers list that will be printed in terminal

  • position (Position) – Position at which it will be printed in terminal

  • size (Size) – Size of buffer in terminal

function: Callable[[], str | List[Self]] = None
position: Position = None
size: Size = None
class shellui.common.types.Collection(elements: List[BaseElementInterface] = None)

Bases: list

Represents an extended list and provides type safety for elements that must implement BaseElementInterface interface

Parameters:

interface_level (Type) – Specifies the elements type that the collection can hold

append(element: BaseElementInterface)

Append object to the end of the list.

call_elements_event(event: str, rule: ~typing.Callable[[~shellui.common.interfaces.BaseElementInterface], bool] = <function Collection.<lambda>>, args: ~typing.List = None, kwargs: ~typing.Dict = None) List[Any]

Calls event with args and kwargs arguments on elements that satisfy rule condition.

Parameters:
  • event (Text) – Event name

  • rule (Callable[[BaseElementInterface], bool]) – Condition function for filtering elements

  • args (List) – Positional arguments that will be passed to event

  • kwargs (Dict) – Named arguments that will be passed to event

Returns:

Returned values of filtered collection elements

Return type:

List[Any]

get_elements_collection(rule: ~typing.Callable[[~shellui.common.interfaces.BaseElementInterface], bool] = <function Collection.<lambda>>) Self

Returns filtered collection of elements that satisfy rule condition.

Parameters:

rule (Callable[[BaseElementInterface], bool]) – Condition function for filtering elements

Returns:

Filtered collection of elements

Return type:

Collection

insert(index: int, element: BaseElementInterface)

Insert object before index.

interface_level

Specifies the elements type that the collection can hold

alias of BaseElementInterface

set_elements_attribute(attribute: str, value: ~typing.Any, rule: ~typing.Callable[[~shellui.common.interfaces.BaseElementInterface], bool] = <function Collection.<lambda>>) Self

Sets attribute value for elements that satisfy rule condition.

Parameters:
  • attribute (Text) – Attribute name to be set

  • value (Any) – Value to set for attribute

  • rule (Callable[[BaseElementInterface], bool]) – Condition function for filtering elements

Returns:

Filtered collection of elements

Return type:

Collection

class shellui.common.types.Dimensions

Bases: ABC

Represent abstract base class of dimensions with basic arithmetic operations.

class shellui.common.types.ElementState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum representing the state of an element.

Parameters:
  • MISSED (int) – Indicates that the element was missed

  • SELECTED (int) – Indicates that the element was selected

MISSED = 0
SELECTED = 1
class shellui.common.types.EventUnit(event_name: str, parent: BaseElementInterface)

Bases: object

Represents event unit that associated function with EventManager class

event_name: str
parent: BaseElementInterface

Parent class object

class shellui.common.types.KeyboardEvent(function: Callable[[], Any], rule: Callable[[int], bool])

Bases: object

Represents a keyboard event.

Parameters:
  • function (Callable[[], Any]) – The function to be executed on the event.

  • rule (Callable[[int], bool]) – Condition function for filtering elements

function: Callable[[], Any]
rule: Callable[[int], bool]
class shellui.common.types.Position(x: int, y: int)

Bases: Dimensions

Represents a position in a 2D space.

Parameters:
  • x (int) – X-coordinate of the position.

  • y (int) – Y-coordinate of the position.

x: int
y: int
class shellui.common.types.Size(width: int, height: int)

Bases: Dimensions

Represents the size with width and height.

Parameters:
  • width (int) – Width dimension.

  • height (int) – Height dimension.

height: int
width: int