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', 'fg': '272b40'}, 'button_hover': {'bg': '3248c0', 'fg': 'fff0f6'}, 'button_normal': {'bg': '2a3ca0', 'fg': 'dde4ed'}, 'button_press': {'bg': 'c4a219', 'fg': 'fff0f6'}, 'data_table_hover': {'bg': '111834', 'fg': 'f6a7a9'}, 'data_table_selected': {'bg': '111f5e', 'fg': 'ecf3ff'}, 'data_table_selected_hover': {'bg': '1b244b', 'fg': 'ecf3ff'}, 'data_table_sort_indicator': {'bg': '070c25', 'fg': 'ecf3ff'}, 'data_table_stripe': {'bg': '0b1238', 'fg': 'f6a7a9'}, 'data_table_stripe_hover': {'bg': '0f184a', 'fg': 'f6a7a9'}, 'markdown_block_code_background': '080b1a', 'markdown_header_background': '030612', 'markdown_image': {'bg': '0c1540', 'fg': 'f6a7a9'}, 'markdown_inline_code': {'bg': '080b1a', 'fg': '806ae5'}, 'markdown_link': {'bg': '070c25', 'fg': '376cff'}, 'markdown_link_hover': {'bg': '070c25', 'fg': '4668ff'}, 'markdown_quote': {'bg': '0c1b4b', 'fg': '2054e2'}, 'markdown_quote_block_code_background': '11265d', 'markdown_title': {'bg': '292a2d', 'fg': 'cfd1d4'}, 'menu_item_disallowed': {'bg': '070c25', 'fg': '272b40'}, 'menu_item_hover': {'bg': '111834', 'fg': 'f2babc'}, 'menu_item_selected': {'bg': '1b244b', 'fg': 'ecf3ff'}, 'primary': {'bg': '070c25', 'fg': 'f6a7a9'}, 'progress_bar': {'bg': '2a3ca0', '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', 'fg': 'f6a7a9'}, 'text_pad_selection_highlight': {'bg': '0f1847', 'fg': 'f6a7a9'}, 'textbox_placeholder': {'bg': '070c25', 'fg': '2a3a92'}, 'textbox_primary': {'bg': '070c25', 'fg': 'fff0f6'}, 'textbox_selection_highlight': {'bg': '0f1847', 'fg': 'fff0f6'}, 'titlebar_inactive': {'bg': '070c25', 'fg': '7d6b71'}, 'titlebar_normal': {'bg': '070c25', '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 app. If not given, try to use terminal foreground.
- bg_colorColor | None, default: None
Background color of app. If not given, try to use 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 app.
bg_color
ColorBackground color of app.
- 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.
- root_Root | None
Root of gadget tree.
children
list[Gadget]Alias for
root.children
.
Methods
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.
- 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', 'fg': '272b40'}, 'button_hover': {'bg': '3248c0', 'fg': 'fff0f6'}, 'button_normal': {'bg': '2a3ca0', 'fg': 'dde4ed'}, 'button_press': {'bg': 'c4a219', 'fg': 'fff0f6'}, 'data_table_hover': {'bg': '111834', 'fg': 'f6a7a9'}, 'data_table_selected': {'bg': '111f5e', 'fg': 'ecf3ff'}, 'data_table_selected_hover': {'bg': '1b244b', 'fg': 'ecf3ff'}, 'data_table_sort_indicator': {'bg': '070c25', 'fg': 'ecf3ff'}, 'data_table_stripe': {'bg': '0b1238', 'fg': 'f6a7a9'}, 'data_table_stripe_hover': {'bg': '0f184a', 'fg': 'f6a7a9'}, 'markdown_block_code_background': '080b1a', 'markdown_header_background': '030612', 'markdown_image': {'bg': '0c1540', 'fg': 'f6a7a9'}, 'markdown_inline_code': {'bg': '080b1a', 'fg': '806ae5'}, 'markdown_link': {'bg': '070c25', 'fg': '376cff'}, 'markdown_link_hover': {'bg': '070c25', 'fg': '4668ff'}, 'markdown_quote': {'bg': '0c1b4b', 'fg': '2054e2'}, 'markdown_quote_block_code_background': '11265d', 'markdown_title': {'bg': '292a2d', 'fg': 'cfd1d4'}, 'menu_item_disallowed': {'bg': '070c25', 'fg': '272b40'}, 'menu_item_hover': {'bg': '111834', 'fg': 'f2babc'}, 'menu_item_selected': {'bg': '1b244b', 'fg': 'ecf3ff'}, 'primary': {'bg': '070c25', 'fg': 'f6a7a9'}, 'progress_bar': {'bg': '2a3ca0', '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', 'fg': 'f6a7a9'}, 'text_pad_selection_highlight': {'bg': '0f1847', 'fg': 'f6a7a9'}, 'textbox_placeholder': {'bg': '070c25', 'fg': '2a3a92'}, 'textbox_primary': {'bg': '070c25', 'fg': 'fff0f6'}, 'textbox_selection_highlight': {'bg': '0f1847', 'fg': 'fff0f6'}, 'titlebar_inactive': {'bg': '070c25', 'fg': '7d6b71'}, 'titlebar_normal': {'bg': '070c25', '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 app.
- bg_colorColor | None, default: None
Background color of app.
- 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.