forked from pythonecuador/lira
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also added a way to setup the title :) Close pythonecuador#100
- Loading branch information
Showing
5 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
from prompt_toolkit.application.current import get_app | ||
from prompt_toolkit.shortcuts import set_title as set_app_title | ||
|
||
|
||
def exit_app(): | ||
"""Exit the app and save any state.""" | ||
get_app().exit() | ||
|
||
|
||
def set_title(title=""): | ||
if not title: | ||
text = "Lira" | ||
else: | ||
text = f"{title} - Lira" | ||
set_app_title(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from prompt_toolkit.application import create_app_session | ||
from prompt_toolkit.input import create_pipe_input | ||
from prompt_toolkit.output import DummyOutput | ||
|
||
from lira.tui import TerminalUI | ||
|
||
|
||
class TestTUI: | ||
def test_layout(self): | ||
input = create_pipe_input() | ||
with create_app_session(input=input, output=DummyOutput()): | ||
tui = TerminalUI() | ||
layout = tui.app.layout | ||
assert len(list(layout.find_all_windows())) > 1 | ||
|
||
children = layout.container.get_children() | ||
assert len(children) == 2 | ||
assert len(children[0].get_children()) == 2 |