greatday.tui module
Functions / classes used to create greatday’s TUI.
- class Context(query, group_name, edit_todos=False)[source]
Bases:
objectMutable TUI Context.
Used to preserve state after closing the GreatApp instance, running vim, and then opening a new GreatApp instance.
- query
The active todo query string.
- Type
str
- group_name
The name of the saved query group to use. This controls which queries are bound to digits (i.e. 0-9) and shown in the stats panel.
- Type
str
- edit_todos
After closing the TUI, should we open up vim to edit matching todos?
- Type
bool
- Parameters
query (
str) –group_name (
str) –edit_todos (
bool) –
- edit_todos = False
- group_name
- query
- class GreatApp(*, repo, ctx, saved_query_group_map, **kwargs)[source]
Bases:
textual.app.App[str]Textual TUI Application Class.
- Parameters
ctx (
Context) –saved_query_group_map (
Dict[str,SavedQueryGroup]) –kwargs (
Any) –
- BINDINGS = [Binding(key='escape', action="change_mode('normal')", description='Normal Mode', show=True, key_display=None, priority=True), Binding(key='enter', action='submit', description='Submit', show=False, key_display=None, priority=True), Binding(key='!', action='change_query_group(0)', description='Change to 1st query group.', show=False, key_display=None, priority=False), Binding(key='@', action='change_query_group(1)', description='Change to 2nd query group.', show=False, key_display=None, priority=False), Binding(key='#', action='change_query_group(2)', description='Change to 3rd query group.', show=False, key_display=None, priority=False), Binding(key='$', action='change_query_group(3)', description='Change to 4th query group.', show=False, key_display=None, priority=False), Binding(key='%', action='change_query_group(4)', description='Change to 5th query group.', show=False, key_display=None, priority=False), Binding(key='^', action='change_query_group(5)', description='Change to 6th query group.', show=False, key_display=None, priority=False), Binding(key='&', action='change_query_group(6)', description='Change to 7th query group.', show=False, key_display=None, priority=False), Binding(key='*', action='change_query_group(7)', description='Change to 8th query group.', show=False, key_display=None, priority=False), Binding(key='(', action='change_query_group(8)', description='Change to 9th query group.', show=False, key_display=None, priority=False), Binding(key=')', action='change_query_group(9)', description='Change to 10th query group.', show=False, key_display=None, priority=False)]
- CSS = '\n Screen {\n layout: grid;\n grid-size: 10;\n grid-gutter: 2;\n padding: 2;\n }\n #stats {\n height: 100%;\n column-span: 3;\n row-span: 9;\n }\n #main {\n height: 100%;\n column-span: 7;\n row-span: 9;\n }\n #command {\n column-span: 10;\n row-span: 1;\n }\n '
Inline CSS, useful for quick scripts. This is loaded after CSS_PATH, and therefore takes priority in the event of a specificity clash.
- async action_change_mode(mode)[source]
Action to toggle to/from insert mode and other modes.
- Parameters
mode (
str) –- Return type
None
- async action_change_query_group(group_idx)[source]
Changes the saved query group that is being used.
- Parameters
group_idx (
int) –- Return type
None
- async action_new_query(query)[source]
Execute a new todo query.
- Parameters
query (
str) –- Return type
None
- async action_refresh()[source]
Full refresh of TUI (e.g. stats + main panel will reload).
- Return type
None
- async action_submit()[source]
Executes the current todo query shown in the input bar.
- Return type
None
- async bind_saved_queries(group_name)[source]
Binds saved queries in group_name to digits (i.e. 0-9).
- Parameters
group_name (
str) –- Return type
None
- dark
Use a dark theme if True, otherwise use a light theme.
Modify this attribute to switch between light and dark themes.
Example
`python self.app.dark = not self.app.dark # Toggle dark mode `
- sub_title
The sub-title for the application.
The initial value for sub_title will be set to the SUB_TITLE class variable if it exists, or an empty string if it doesn’t.
Sub-titles are typically used to show the high-level state of the app, such as the current mode, or path to the file being worker on.
Assign a new value to this attribute to change the sub-title.
- title
The title for the application.
The initial value for title will be set to the TITLE class variable if it exists, or the name of the app if it doesn’t.
Assign a new value to this attribute to change the title.
Bases:
textual.widgets._footer.FooterOverride the default Footer for Styling
Widget may receive focus.
Widget’s children may receive focus.
- class GreatHeader[source]
Bases:
textual.widgets._header.HeaderOverride the default Header for Styling
- can_focus = False
Widget may receive focus.
- can_focus_children = True
Widget’s children may receive focus.
- tall
Set to True for a taller header or False for a single line header.
- class Stats(count, points)[source]
Bases:
objectTodo query stats.
- count
number of todos matched by this query.
- Type
int
- points
Sum of points (i.e. ‘p’) or expected points (i.e. ‘xp’) for todos matching this query.
- Type
int
- Parameters
count (
int) –points (
int) –
- count
- points
- class StatsGroup(all_stats, done_stats, open_stats)[source]
Bases:
objectTodo query stats group.
- all_stats
Stats on all todos matching this query.
- Type
- done_stats
Stats on all completed todos matching this query.
- Type
- open_stats
Stats on all un-completed (i.e. not done) todos matching this query.
- Type
- all_stats
- done_stats
- classmethod from_todos(todos)[source]
Constructs a StatsGroup from an iterable of todos (or None).
- Parameters
todos (Sequence[GreatTodo] | None) –
- Return type
- open_stats
- class StatsWidget(repo, ctx, saved_query_group_map, *args, **kwargs)[source]
Bases:
textual.widgets._static.StaticWidget that shows Todo statistics.
- Parameters
ctx (
Context) –saved_query_group_map (
Dict[str,SavedQueryGroup]) –args (
Any) –kwargs (
Any) –
- can_focus = True
Widget may receive focus.
- can_focus_children = True
Widget’s children may receive focus.
- get_default_query(saved_query_group_map, group_name)[source]
Returns the name of the configured default query for a query group.
Helper function that hides the details of parsing the SavedQueryGroup data structure.
- Parameters
saved_query_group_map (
Dict[str,SavedQueryGroup]) – Contains the query group we are interested in.group_name (
str) – Name of the query group we are interested in.
- Return type
str