euporie.core.widgets.forms
Contain input widgets.
Functions
|
A decorator indicating abstract methods. |
|
Align formatted text at a given width. |
|
Cast a value to a type. |
|
Return the ceiling of x as an Integral. |
|
Turn a list of (style_str, text) tuples into another list where each string is exactly one character. |
|
Return the floor of x as an Integral. |
|
Return the amount of characters in this text fragment list. |
|
Return the character width of this text fragment list. |
|
Get the current active (running) Application. |
|
Enable when this buffer has the focus. |
|
Test whether value is True. |
|
Merge multiple |
|
Accept both booleans and Filters as input and turn it into a Filter. |
|
Convert the given value (which can be formatted text) into a list of text fragments. |
Classes
|
Metaclass for defining Abstract Base Classes (ABCs). |
|
Insert text after the input. |
|
Always enable feature. |
|
A clickable button widget which contains another container. |
|
Insert text before the input. |
|
Draw a border around any container. |
|
Add padding around a container. |
|
The core data structure that holds the text and cursor position of the current input line and implements all text manipulations on top of it. |
|
Control for visualizing the content of a |
|
A clickable button widget which holds text. |
|
A toggleable checkbox widget. |
Base class for completer implementations. |
|
|
Turn any callable into a Filter. |
|
Wrapper around any other completer that will enable/disable the completions depending on whether the received condition is satisfied. |
|
Wrapper around any other container that can change the visibility. |
|
Wraps around a KeyBindings. Disable/enable all the key bindings according to the given (additional) filter.::. |
|
Processor that applies another processor, according to a certain condition. Example::. |
|
A split container where the orientation depends on a filter. |
|
A tuple of four bools with directions. |
|
A tuple of four integers with directions. |
|
Specified dimension (width/height) of a user control or window. |
|
This is a immutable class around the text and cursor position, and contains methods for querying this data, e.g. to give the text before the cursor. |
|
A dropdown widget, allowing selection of an item from a menu of options. |
|
Validator class that can dynamically returns any Validator. |
|
Container class that dynamically returns any Container. |
|
Lexer class that can dynamically returns any Lexer. |
|
Simple event to which event handlers can be attached. For instance::. |
|
A sub-class of |
|
Base class for any filter to activate/deactivate a feature, depending on a condition. |
|
Float for use in a |
|
Alignment of formatted text. |
|
Control that displays formatted text. |
A container for a set of key bindings. |
|
|
A label widget which displays rich text. |
|
A widget which applies a label to another widget. |
|
Base class for all lexers. |
|
A container which renders a stand-alone margin. |
|
|
|
Mouse event, sent to UIControl.mouse_handler. |
|
|
|
A container which wraps mouse events to add a mouse handler. |
|
Formatted text control where the cursor can be moved by scrolling. |
|
Processor that masks the input. |
|
|
Manipulate the fragments for a given line in a |
|
|
A progress-bar widget. |
|
A control which draws a progress-bar. |
|
Margin displaying a scrollbar. |
|
A select widget, which allows one or more items to be selected from a list. |
|
Base class for widgets where one or more items can be selected. |
|
Draw a shadow underneath/behind this container. |
|
Very simple cache that discards the oldest item when the cache size is exceeded. |
|
Mask with restricted number of True items. |
|
A slider widget with an optional editable readout. |
|
A control to display a slider. |
|
An widget which displays a given color. |
|
A text input widget. |
|
A toggleable button widget. |
|
A widget where an option is selected using mutually exclusive toggle-buttons. |
Base class for toggleable widgets. |
|
|
Content generated by a user control. |
Base class for all user interface controls. |
|
|
Several layouts, one stacked left/right of the other. |
|
The validation state of a buffer. |
Abstract base class for an input validator. |
|
|
Container that holds a control. |
|
Alignment of the Window content. |
|
Simple autocompletion on a list of words. |
|
|
A list-like sequence optimized for data accesses near its endpoints. |
|
|
Class for finalization of weakrefable objects |
|
Create a new function with partial application of the given arguments and keywords. |
- class euporie.core.widgets.forms.BaseButton(body: AnyContainer, on_click: Callable[[BaseButton], None] | None = None, on_mouse_down: Callable[[BaseButton], None] | None = None, disabled: FilterOrBool = False, style: str | Callable[[], str] = 'class:input', border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, padding: DiInt | None = None, selected: bool = False, key_bindings: KeyBindingsBase | None = None, mouse_handler: Callable[[MouseEvent], NotImplementedOrNone] | None = None)
Bases:
objectA clickable button widget which contains another container.
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- get_key_bindings() KeyBindingsBase
Key bindings for the Button.
- class euporie.core.widgets.forms.Button(text: AnyFormattedText, width: AnyDimension | None = None, align: WindowAlign = WindowAlign.CENTER, dont_extend_height: FilterOrBool = True, dont_extend_width: FilterOrBool = True, on_click: Callable[[BaseButton], None] | None = None, on_mouse_down: Callable[[BaseButton], None] | None = None, disabled: FilterOrBool = False, style: str | Callable[[], str] = 'class:input', border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, padding: DiInt | None = None, selected: bool = False, key_bindings: KeyBindingsBase | None = None, mouse_handler: Callable[[MouseEvent], NotImplementedOrNone] | None = None)
Bases:
BaseButtonA clickable button widget which holds text.
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- get_key_bindings() KeyBindingsBase
Key bindings for the Button.
- class euporie.core.widgets.forms.Checkbox(text: AnyFormattedText = '', on_click: Callable[[ToggleableWidget], None] | None = None, prefix: tuple[str, str] = ('☐', '☑'), style: str = 'class:input', selected: bool = False, disabled: FilterOrBool = False, key_bindings: KeyBindingsBase | None = None)
Bases:
ToggleableWidgetA toggleable checkbox widget.
- container: AnyContainer
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
- key_bindings: KeyBindingsBase | None
- class euporie.core.widgets.forms.Dropdown(options: list[Any], labels: Sequence[AnyFormattedText] | None = None, index: int | None = None, indices: list[int] | None = None, n_values: int | None = None, multiple: FilterOrBool = False, max_count: int | None = None, on_change: Callable[[SelectableWidget], None] | None = None, style: str | Callable[[], str] = 'class:input', arrow: str = '⯆', disabled: FilterOrBool = False, width: int | None = None, expand: FilterOrBool = True)
Bases:
SelectableWidgetA dropdown widget, allowing selection of an item from a menu of options.
- button_text() StyleAndTextTuples
Return the text to display on the button.
Close the menu and untoggle the button.
- key_bindings() KeyBindingsBase
Return key-bindings for the drop-down widget.
- load_container() AnyContainer
Load the widget’s container.
Return formatted text fragment to display in the menu.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- mouse_handler_button(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
Handle mouse events.
Close the menu and untoggle the button.
- class euporie.core.widgets.forms.ExpandingBufferControl(buffer: Buffer | None = None, input_processors: list[Processor] | None = None, include_default_input_processors: bool = True, lexer: Lexer | None = None, preview_search: FilterOrBool = False, focusable: FilterOrBool = True, search_buffer_control: OptionalSearchBuffer = None, menu_position: Callable[[], int | None] | None = None, focus_on_click: FilterOrBool = False, key_bindings: KeyBindingsBase | None = None, expand: FilterOrBool = True, on_focus: Callable[[], None] | None = None)
Bases:
BufferControlA sub-class of
BufferControlwhich expands to the available width.- create_content(width: int, height: int, preview_search: bool = False) UIContent
Create a UIContent.
- get_key_bindings() KeyBindingsBase | None
When additional key bindings are given. Return these.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Optionally call focus handler when focused.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None
- preferred_width(max_available_width: int) int | None
Enure text box expands to available width.
- Parameters:
max_available_width – The maximum available width
- Returns:
The desired width, which is the maximum available
- property search_buffer_control: SearchBufferControl | None
- property search_state: SearchState
Return the SearchState for searching this BufferControl. This is always associated with the search control. If one search bar is used for searching multiple BufferControls, then they share the same SearchState.
- class euporie.core.widgets.forms.Label(value: AnyFormattedText, style: str | Callable[[], str] = 'class:input', html: FilterOrBool = False, dont_extend_height: FilterOrBool = True, dont_extend_width: FilterOrBool = True, align: WindowAlign | Callable[[], WindowAlign] = WindowAlign.LEFT, wrap_lines: FilterOrBool = True)
Bases:
objectA label widget which displays rich text.
- get_value() AnyFormattedText
Return the current value of the label, converting to formatted text.
- class euporie.core.widgets.forms.LabelledWidget(body: AnyContainer, label: AnyFormattedText, style: str = 'class:input', vertical: FilterOrBool = False, html: FilterOrBool = False)
Bases:
objectA widget which applies a label to another widget.
Bases:
FormattedTextControlFormatted text control where the cursor can be moved by scrolling.
Generate the content for this user control.
Returns a
UIContentinstance.
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
The key bindings that are specific for this user control.
Return a
KeyBindingsobject if some key bindings are specified, or None otherwise.
Tell whether this user control is focusable.
Handle mouse events.
(When the fragment list contained mouse handlers and the user clicked on on any of these, the matching handler is called. This handler can still return NotImplemented in case we want the
Windowto handle this particular event.)
Request to move the cursor down.
This happens when scrolling down and the cursor is completely at the top.
Request to move the cursor up.
Return the preferred height for this control.
Return the preferred width for this control. That is the width of the longest line.
- class euporie.core.widgets.forms.Progress(start: float | int = 0, stop: float | int = 100, step: float | int = 1, value: float | int = 0, vertical: FilterOrBool = False, style: str | Callable[[], str] = 'class:input')
Bases:
objectA progress-bar widget.
- class euporie.core.widgets.forms.ProgressControl(start: float | int = 0, stop: float | int = 100, step: float | int = 1, value: float | int = 0, vertical: Filter | bool = False)
Bases:
UIControlA control which draws a progress-bar.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindingsobject if some key bindings are specified, or None otherwise.
- hchars = ('', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█')
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
When NotImplemented is returned, it means that the given event is not handled by the UIControl itself. The Window or key bindings can decide to handle this event as scrolling or changing focus.
- Parameters:
mouse_event – MouseEvent instance.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None
Determine the height of the progress-bar depending on its orientation.
- preferred_width(max_available_width: int) int | None
Determine the width of the progress-bar depending on its orientation.
- render(width: int, height: int) list[StyleAndTextTuples]
Render the progressbar at a given size as lines of formatted text.
- vchars = ('', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█')
- class euporie.core.widgets.forms.Select(options: list[Any], labels: Sequence[AnyFormattedText] | None = None, index: int | None = None, indices: list[int] | None = None, n_values: int | None = None, multiple: FilterOrBool = False, max_count: int | None = None, on_change: Callable[[SelectableWidget], None] | None = None, style: str | Callable[[], str] = 'class:input,select', rows: int | None = 3, prefix: tuple[str, str] = ('', ''), border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, disabled: FilterOrBool = False, dont_extend_width: FilterOrBool = True, dont_extend_height: FilterOrBool = True)
Bases:
SelectableWidgetA select widget, which allows one or more items to be selected from a list.
- key_bindings() KeyBindingsBase
Key bindings for the selectable widget.
- load_container() AnyContainer
Load the widget’s container.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- text_fragments() StyleAndTextTuples
Create a list of formatted text fragments to display.
- class euporie.core.widgets.forms.SelectableWidget(options: list[Any], labels: Sequence[AnyFormattedText] | None = None, index: int | None = None, indices: list[int] | None = None, n_values: int | None = None, multiple: FilterOrBool = False, max_count: int | None = None, on_change: Callable[[SelectableWidget], None] | None = None, style: str | Callable[[], str] = 'class:input', disabled: FilterOrBool = False)
Bases:
objectBase class for widgets where one or more items can be selected.
- key_bindings() KeyBindingsBase
Key bindings for the selectable widget.
- abstractmethod load_container() AnyContainer
Abstract method for loading the widget’s container.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- class euporie.core.widgets.forms.SizedMask(size: int | None = None)
-
Mask with restricted number of True items.
- copy()
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- items()
Return a set-like object providing a view on the dict’s items.
- keys()
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()
Return an object providing a view on the dict’s values.
- class euporie.core.widgets.forms.Slider(options: list[Any], labels: Sequence[AnyFormattedText] | None = None, index: int | None = None, indices: list[int] | None = None, n_values: int | None = None, multiple: FilterOrBool = False, max_count: int | None = None, on_change: Callable[[SelectableWidget], None] | None = None, style: str | Callable[[], str] = 'class:input', border: GridStyle = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, vertical: FilterOrBool = False, show_arrows: FilterOrBool = True, arrows: tuple[AnyFormattedText, AnyFormattedText] = ('-', '+'), show_readout: FilterOrBool = True, disabled: FilterOrBool = False)
Bases:
SelectableWidgetA slider widget with an optional editable readout.
- control: SliderControl
- key_bindings() KeyBindingsBase
Key bindings for the selectable widget.
- load_container() AnyContainer
Build the slider’s container.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- value_changed(slider: SelectableWidget | None = None) None
Set the readout text when the slider value changes.
- class euporie.core.widgets.forms.SliderControl(slider: Slider, show_arrows: Filter | bool = True, handle_char: str = '●', track_char: str | None = None, selected_track_char: str | None = None, style: str = 'class:input', disabled: Filter | bool = False)
Bases:
UIControlA control to display a slider.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
Key bindings for the Slider.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events given the slider’s orientation.
- mouse_handler_(mouse_event: MouseEvent, loc: int) NotImplementedOrNone
Handle mouse events.
- mouse_handler_arrow(mouse_event: MouseEvent, n: int = 0) NotImplementedOrNone
Handle mouse events on the slider’s arrows.
- mouse_handler_handle(mouse_event: MouseEvent, handle: int = 0) NotImplementedOrNone
Handle mouse events on the slider’s handles.
- mouse_handler_scroll(mouse_event: MouseEvent, handle: int | None = None) NotImplementedOrNone
Handle mouse scroll events.
- mouse_handler_track(mouse_event: MouseEvent, index: int = 0) NotImplementedOrNone
Handle mouse events on the slider track.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None
Return the preferred height of the slider control given its orientation.
- preferred_width(max_available_width: int) int | None
Return the preferred width of the slider control given its orientation.
- render_lines(width: int, height: int) list[StyleAndTextTuples]
Generate formatted text fragments to display the slider.
- class euporie.core.widgets.forms.Swatch(color: str | Callable[[], str] = '#FFFFFF', width: int = 2, height: int = 1, style: str | Callable[[], str] = 'class:input, swatch', border: GridStyle = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔, show_borders: DiBool | None = None)
Bases:
objectAn widget which displays a given color.
- class euporie.core.widgets.forms.Text(text: str = '', style: str = 'class:input', height: int = 1, min_height: int = 1, multiline: FilterOrBool = False, expand: FilterOrBool = True, width: int | None = None, completer: Completer | None = None, options: list[str] | Callable[[], list[str]] | None = None, show_borders: DiBool | None = None, on_text_changed: Callable[[Buffer], None] | None = None, validation: Callable[[str], bool] | None = None, accept_handler: BufferAcceptHandler | None = None, placeholder: str | None = None, lexer: Lexer | None = None, input_processors: Sequence[Processor] | None = None, disabled: FilterOrBool = False, password: FilterOrBool = False, wrap_lines: FilterOrBool = False, prompt: AnyFormattedText | None = None, on_focus: Callable[[], None] | None = None, complete_while_typing: FilterOrBool = True, auto_suggest: AutoSuggest | None = None)
Bases:
objectA text input widget.
- class euporie.core.widgets.forms.ToggleButton(text: AnyFormattedText, on_click: Callable[[ToggleButton], None] | None = None, width: int | None = None, style: str | Callable[[], str] = 'class:input', border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, selected: bool = False, disabled: FilterOrBool = False, key_bindings: KeyBindingsBase | None = None, mouse_handler: Callable[[MouseEvent], NotImplementedOrNone] | None = None, dont_extend_height: FilterOrBool = True, dont_extend_width: FilterOrBool = True, padding: DiInt | None = None)
Bases:
ToggleableWidgetA toggleable button widget.
- container: AnyContainer
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
- key_bindings: KeyBindingsBase | None
- class euporie.core.widgets.forms.ToggleButtons(options: list[Any], labels: Sequence[AnyFormattedText] | None = None, index: int | None = None, indices: list[int] | None = None, n_values: int | None = None, multiple: FilterOrBool = False, max_count: int | None = None, on_change: Callable[[SelectableWidget], None] | None = None, style: str | Callable[[], str] = 'class:input', border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , disabled: FilterOrBool = False, vertical: FilterOrBool = False)
Bases:
SelectableWidgetA widget where an option is selected using mutually exclusive toggle-buttons.
- key_bindings() KeyBindingsBase
Return key-bindings for the drop-down widget.
- load_container() AnyContainer
Load the widget’s container.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- update_buttons(widget: SelectableWidget | None = None) None
Set the toggle buttons’ selection state when the selected index changes.
- class euporie.core.widgets.forms.ToggleableWidget
Bases:
objectBase class for toggleable widgets.
- container: AnyContainer
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
- key_bindings: KeyBindingsBase | None