batgrl.app#
Base for creating terminal applications.
Functions
|
Run a gadget as an app. |
Classes
|
Base for creating terminal applications. |
- class batgrl.app.App(*, fg_color: Color | None = None, bg_color: Color | None = None, title: str | None = None, inline: bool = False, inline_height: int = 10, color_theme: ColorTheme = {'button_disallowed_bg': '070c25', 'button_disallowed_fg': '272b40', 'button_hover_bg': '3248c0', 'button_hover_fg': 'fff0f6', 'button_normal_bg': '2a3ca0', 'button_normal_fg': 'dde4ed', 'button_press_bg': 'c4a219', 'button_press_fg': 'fff0f6', 'data_table_hover_bg': '111834', 'data_table_hover_fg': 'f6a7a9', 'data_table_selected_bg': '111f5e', 'data_table_selected_fg': 'ecf3ff', 'data_table_selected_hover_bg': '1b244b', 'data_table_selected_hover_fg': 'ecf3ff', 'data_table_sort_indicator_bg': '070c25', 'data_table_sort_indicator_fg': 'ecf3ff', 'data_table_stripe_bg': '0b1238', 'data_table_stripe_fg': 'f6a7a9', 'data_table_stripe_hover_bg': '0f184a', 'data_table_stripe_hover_fg': 'f6a7a9', 'markdown_block_code_bg': '080b1a', 'markdown_header_bg': '030612', 'markdown_image_bg': '0c1540', 'markdown_image_fg': 'f6a7a9', 'markdown_inline_code_bg': '080b1a', 'markdown_inline_code_fg': '806ae5', 'markdown_link_bg': '070c25', 'markdown_link_fg': '376cff', 'markdown_link_hover_bg': '070c25', 'markdown_link_hover_fg': '4668ff', 'markdown_quote_bg': '0c1b4b', 'markdown_quote_block_code_bg': '11265d', 'markdown_quote_fg': '2054e2', 'markdown_title_bg': '292a2d', 'markdown_title_fg': 'cfd1d4', 'menu_item_disallowed_bg': '070c25', 'menu_item_disallowed_fg': '272b40', 'menu_item_hover_bg': '111834', 'menu_item_hover_fg': 'f2babc', 'menu_item_selected_bg': '1b244b', 'menu_item_selected_fg': 'ecf3ff', 'primary_bg': '070c25', 'primary_fg': 'f6a7a9', 'progress_bar_bg': '2a3ca0', 'progress_bar_fg': 'ffe0df', 'scroll_view_indicator_hover': '111e4f', 'scroll_view_indicator_normal': '0e1843', 'scroll_view_indicator_press': '172868', 'scroll_view_scrollbar': '070c25', 'text_pad_line_highlight_bg': '0c0e30', 'text_pad_line_highlight_fg': 'f6a7a9', 'text_pad_selection_highlight_bg': '0f1847', 'text_pad_selection_highlight_fg': 'f6a7a9', 'textbox_placeholder_bg': '070c25', 'textbox_placeholder_fg': '2a3a92', 'textbox_primary_bg': '070c25', 'textbox_primary_fg': 'fff0f6', 'textbox_selection_highlight_bg': '0f1847', 'textbox_selection_highlight_fg': 'fff0f6', 'titlebar_inactive_bg': '070c25', 'titlebar_inactive_fg': '7d6b71', 'titlebar_normal_bg': '070c25', 'titlebar_normal_fg': 'ffe0df', 'window_border_inactive': '282c3e', 'window_border_normal': '122162'}, double_click_timeout: float = 0.5, render_interval: float = 0.0, redirect_stderr: Path | None = None)#
Bases:
ABC
Base for creating terminal applications.
- Parameters:
- fg_colorColor | None, default: None
Foreground color of the root gadget. If not given, the app will try to use the terminal foreground.
- bg_colorColor | None, default: None
Background color of the root gadget. If not given, the app will try to use the terminal background.
- titlestr | None, default: None
The terminal’s title.
- inlinebool, default: False
Whether to render app inline or in the alternate screen.
- inline_height :int, default: 10
Height of app if rendered inline.
- color_themeColorTheme, default: DEFAULT_COLOR_THEME
Color theme for
batgrl.gadgets.behaviors.themable.Themable
gadgets.- double_click_timeoutfloat, default: 0.5
Max duration of a double-click.
- render_intervalfloat, default: 0.0
Duration in seconds between consecutive frame renders.
- redirect_stderrPath | None, default: None
If provided, stderr is written to this path.
- Attributes:
fg_color
Color | NoneForeground color of the root gadget.
bg_color
ColorBackground color of the root gadget.
- titlestr | None
The terminal’s title.
inline
boolWhether to render app inline or in the alternate screen buffer.
- inline_height :int
Height of app if rendered inline.
color_theme
ColorThemeColor theme for themable gadgets.
- double_click_timeoutfloat
Max duration of a double-click.
- render_intervalfloat
Duration in seconds between consecutive frame renders.
- redirect_stderrPath | None
Path where stderr is saved.
sixel_support
boolWhether sixel is supported.
sixel_geometry
SizeCurrent sixel geometry.
sixel_aspect_ratio
SizeCurrent sixel aspect ratio.
- root_Root | None
Root of gadget tree.
children
list[Gadget]Alias for
root.children
.
Methods
set_sixel_aspect_ratio(aspect_ratio)
Set sixel aspect ratio.
on_start()
Coroutine scheduled when app is run.
run()
Run the app.
exit(exit_value)
Exit the app.
add_gadget(gadget)
Alias for
root.add_gadget
.add_gadgets(*gadgets)
Alias for
root.add_gadgets
.- add_gadget(gadget: Gadget) None #
Alias for
root.add_gadget
.- Parameters:
- gadgetGadget
A gadget to add as a child to the root gadget.
- add_gadgets(*gadgets: Gadget) None #
Alias for
root.add_gadgets
.- Parameters:
- *gadgetsGadget
Gadgets to add as children to the root gadget.
- property color_theme: ColorTheme#
Color theme for Themable gadgets.
- double_click_timeout#
Max duration of a double-click.
- exit(exit_value: Any = None) None #
Exit the app.
- Parameters:
- exit_valueAny, default: None
Value returned by
run()
.
- property inline: bool#
Whether to render app inline or in the alternate screen buffer.
- property inline_height: int#
Height of app if rendered inline.
- property is_running: bool#
Whether app is running.
- abstract async on_start()#
Coroutine scheduled when app is run.
- redirect_stderr#
Path where stderr is saved.
- render_interval#
Duration in seconds between consecutive frame renders.
- root: _Root | None#
Root of gadget tree (only set while app is running).
- run() Any #
Run the app.
- set_sixel_aspect_ratio(aspect_ratio: Size) None #
Set sixel aspect ratio.
- Parameters:
- aspect_ratioSize
The desired aspect ratio. Aspect width must be 1 and aspect height must divide sixel geometry height.
- property sixel_support: bool#
Whether sixel is supported.
Will return
False
before app has run.
- title#
The terminal’s title.
- batgrl.app.run_gadget_as_app(gadget: Gadget, *, fg_color: Color | None = None, bg_color: Color | None = None, title: str | None = None, inline: bool = False, inline_height: int = 10, color_theme: ColorTheme = {'button_disallowed_bg': '070c25', 'button_disallowed_fg': '272b40', 'button_hover_bg': '3248c0', 'button_hover_fg': 'fff0f6', 'button_normal_bg': '2a3ca0', 'button_normal_fg': 'dde4ed', 'button_press_bg': 'c4a219', 'button_press_fg': 'fff0f6', 'data_table_hover_bg': '111834', 'data_table_hover_fg': 'f6a7a9', 'data_table_selected_bg': '111f5e', 'data_table_selected_fg': 'ecf3ff', 'data_table_selected_hover_bg': '1b244b', 'data_table_selected_hover_fg': 'ecf3ff', 'data_table_sort_indicator_bg': '070c25', 'data_table_sort_indicator_fg': 'ecf3ff', 'data_table_stripe_bg': '0b1238', 'data_table_stripe_fg': 'f6a7a9', 'data_table_stripe_hover_bg': '0f184a', 'data_table_stripe_hover_fg': 'f6a7a9', 'markdown_block_code_bg': '080b1a', 'markdown_header_bg': '030612', 'markdown_image_bg': '0c1540', 'markdown_image_fg': 'f6a7a9', 'markdown_inline_code_bg': '080b1a', 'markdown_inline_code_fg': '806ae5', 'markdown_link_bg': '070c25', 'markdown_link_fg': '376cff', 'markdown_link_hover_bg': '070c25', 'markdown_link_hover_fg': '4668ff', 'markdown_quote_bg': '0c1b4b', 'markdown_quote_block_code_bg': '11265d', 'markdown_quote_fg': '2054e2', 'markdown_title_bg': '292a2d', 'markdown_title_fg': 'cfd1d4', 'menu_item_disallowed_bg': '070c25', 'menu_item_disallowed_fg': '272b40', 'menu_item_hover_bg': '111834', 'menu_item_hover_fg': 'f2babc', 'menu_item_selected_bg': '1b244b', 'menu_item_selected_fg': 'ecf3ff', 'primary_bg': '070c25', 'primary_fg': 'f6a7a9', 'progress_bar_bg': '2a3ca0', 'progress_bar_fg': 'ffe0df', 'scroll_view_indicator_hover': '111e4f', 'scroll_view_indicator_normal': '0e1843', 'scroll_view_indicator_press': '172868', 'scroll_view_scrollbar': '070c25', 'text_pad_line_highlight_bg': '0c0e30', 'text_pad_line_highlight_fg': 'f6a7a9', 'text_pad_selection_highlight_bg': '0f1847', 'text_pad_selection_highlight_fg': 'f6a7a9', 'textbox_placeholder_bg': '070c25', 'textbox_placeholder_fg': '2a3a92', 'textbox_primary_bg': '070c25', 'textbox_primary_fg': 'fff0f6', 'textbox_selection_highlight_bg': '0f1847', 'textbox_selection_highlight_fg': 'fff0f6', 'titlebar_inactive_bg': '070c25', 'titlebar_inactive_fg': '7d6b71', 'titlebar_normal_bg': '070c25', 'titlebar_normal_fg': 'ffe0df', 'window_border_inactive': '282c3e', 'window_border_normal': '122162'}, double_click_timeout: float = 0.5, render_interval: float = 0.0, redirect_stderr: Path | None = None) Any #
Run a gadget as an app.
This convenience function provided for cases when the app would only have a single gadget.
- Parameters:
- gadgetGadget
A gadget to run as an app.
- fg_colorColor | None, default: None
Foreground color of the root gadget.
- bg_colorColor | None, default: None
Background color of the root gadget.
- titlestr | None, default: None
The terminal’s title.
- inlinebool, default: False
Whether to render app inline or in the alternate screen.
- inline_height :int, default: 10
Height of app if rendered inline.
- color_themeColorTheme, default: DEFAULT_COLOR_THEME
Color theme for
batgrl.gadgets.behaviors.themable.Themable
gadgets.- double_click_timeoutfloat, default: 0.5
Max duration of a double-click.
- render_intervalfloat, default: 0.0
Duration in seconds between consecutive frame renders.
- redirect_stderrPath | None, default: None
If provided, stderr is written to this path.