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. |
|
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. |
|
Draw a border around any container. |
|
Add padding around a container. |
|
Control for visualising the content of a |
|
A clickable button widget. |
|
A toggleable checkbox widget. |
|
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. |
|
Specified dimension (width/height) of a user control or window. |
|
A dropdown widget, allowing selection of an item from a menu of options. |
|
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. |
|
A container which renders a stand-alone margin. |
|
|
|
Mouse event, sent to UIControl.mouse_handler. |
|
|
|
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 simple input field. |
|
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. |
|
Simple autocompletion on a list of words. |
|
|
deque([iterable[, maxlen]]) --> deque object |
|
|
Class for finalization of weakrefable objects |
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
- class euporie.core.widgets.forms.Button(text: AnyFormattedText, on_click: Callable[[Button], None] | None = None, on_mouse_down: Callable[[Button], None] | None = None, disabled: FilterOrBool = False, width: int | None = None, style: str | Callable[[], str] = 'class:input', border: GridStyle | None = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔ , show_borders: DiBool | None = None, selected: bool = False, key_bindings: KeyBindingsBase | None = None, mouse_handler: Callable[[MouseEvent], NotImplementedOrNone] | None = None)
Bases:
object
A clickable button widget.
- default_mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- get_key_bindings() KeyBindingsBase
Key bindings for the Button.
- get_text_fragments() StyleAndTextTuples
Return the list of formatted text fragments which define 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:
euporie.core.widgets.forms.ToggleableWidget
A toggleable checkbox widget.
- container: AnyContainer
- key_bindings: KeyBindingsBase | None
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
- 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)
Bases:
euporie.core.widgets.forms.SelectableWidget
A dropdown widget, allowing selection of an item from a menu of options.
- button_text() StyleAndTextTuples
Return the text to display on 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: prompt_toolkit.mouse_events.MouseEvent) None
Handle mouse events.
Show or hide the menu.
- property value: Any
Return the selected value.
- 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)
Bases:
prompt_toolkit.layout.controls.BufferControl
A sub-class of
BufferControl
which expands to the available width.- create_content(width: int, height: int, preview_search: bool = False) prompt_toolkit.layout.controls.UIContent
Create a UIContent.
- get_key_bindings() KeyBindingsBase | None
When additional key bindings are given. Return these.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Mouse handler for this control.
- 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: prompt_toolkit.buffer.Buffer | None
- property search_buffer_control: prompt_toolkit.layout.controls.SearchBufferControl | None
- property search_state: prompt_toolkit.search.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)
Bases:
object
A 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:
object
A widget which applies a label to another widget.
- property html: prompt_toolkit.filters.base.Filter
Get the HTML filter value.
- 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:
object
A 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: Union[prompt_toolkit.filters.base.Filter, bool] = False)
Bases:
prompt_toolkit.layout.controls.UIControl
A control which draws a progress-bar.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.UIContent
Get or render content for a given output size.
- 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
KeyBindings
object 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:
euporie.core.widgets.forms.SelectableWidget
A 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.
- property value: Any
Return the selected value.
- 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:
object
Base class for widgets where one or more items can be selected.
- key_bindings() KeyBindingsBase
Key bindings for the selectable widget.
- abstract load_container() AnyContainer
Abstract method for loading the widget’s container.
- mouse_handler(i: int, mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
- property value: Any
Return the selected value.
- class euporie.core.widgets.forms.SizedMask(size: int | None = None)
-
Mask with restricted number of True items.
- copy() a shallow copy of D
- fromkeys(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() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D'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 dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: 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() an object providing a view on D'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:
euporie.core.widgets.forms.SelectableWidget
A 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.
- property value: Any
Return the selected value.
- value_changed(slider: euporie.core.widgets.forms.SelectableWidget | None = None) None
Set the readout text when the slider value changes.
- class euporie.core.widgets.forms.SliderControl(slider: euporie.core.widgets.forms.Slider, show_arrows: Union[prompt_toolkit.filters.base.Filter, bool] = True, handle_char: str = '●', track_char: str | None = None, selected_track_char: str | None = None, style: str = 'class:input')
Bases:
prompt_toolkit.layout.controls.UIControl
A control to display a slider.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.UIContent
Create an cache the rendered control fragments.
- 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.
- async repeat(mouse_event: MouseEvent, handler: Callable[..., NotImplementedOrNone], timeout: float = 0.25, **kwargs: Any) None
Repeat a mouse event after a timeout.
- class euporie.core.widgets.forms.Swatch(color: str | Callable[[], str] = '#FFFFFF', width: int = 2, height: int = 1, style: str = 'class:swatch', border: GridStyle = ▁▁ 🮇 │▎ 🮇─┼▎ ▔▔, show_borders: DiBool | None = None)
Bases:
object
An 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)
Bases:
object
A 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)
Bases:
euporie.core.widgets.forms.ToggleableWidget
A toggleable button widget.
- container: AnyContainer
- key_bindings: KeyBindingsBase | None
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.
- 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:
euporie.core.widgets.forms.SelectableWidget
A 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: euporie.core.widgets.forms.SelectableWidget | None = None) None
Set the toggle buttons’ selection state when the selected index changes.
- property value: Any
Return the selected value.
- class euporie.core.widgets.forms.ToggleableWidget
Bases:
object
Base class for toggleable widgets.
- container: AnyContainer
- key_bindings: KeyBindingsBase | None
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Focus on mouse down and toggle state on mouse up.