-
I'm trying to write a Layout to the console and reserve a few lines at the bottom of the screen for console.input(); I also want Can someone point me to an example of what I'm trying to accomplish or give me a code snippet to do this ? My latest unsuccessful attempt to control the height of the formatted output is below - look for the "<--": layout = Layout(name="root")
layout.split(
Layout(name="header", size=3),
Layout(name="main", ratio=1),
Layout(name="save_stats_and_unsaved", size=4),
Layout(name="errors", size=6),
)
layout["main"].split_row(
Layout(name="left_side"),
Layout(name="words_by_length", ratio=2, minimum_size=60),
Layout(name="words_by_order"),
)
# (extraneous code not posted)
with console.screen() as screen:
while True:
layout["words_by_order"].update(function1())
layout["save_stats_and_unsaved"].update(function2())
layout["words_by_length"].update(function3())
layout["root"].height = console.height - 4 # <-- restrict the height of the formatted output
layout["root"].ratio = None
console.clear()
screen.update(layout)
input_line = console.input("\nenter a word: ")
# process the input, yadda yadda yadda Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found a solution after digging into the source code for "rich". I discarded this (from my original post): layout["root"].height = console.height - 4 # <-- restrict the height of the formatted output
layout["root"].ratio = None and added this in its place: _width, _height = shutil.get_terminal_size()
console.size = (_width-1, _height-4) by the way, I'm running Windows 10, Python 3.7 and testing my results in cmd.exe and PyCharm |
Beta Was this translation helpful? Give feedback.
I found a solution after digging into the source code for "rich". I discarded this (from my original post):
and added this in its place:
by the way, I'm running Windows 10, Python 3.7 and testing my results in cmd.exe and PyCharm