Python 终端/文本 UI (TUI) 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22394090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:52:04  来源:igfitidea点击:

Python Terminal/Text UI (TUI) library

pythonuser-interfaceconsoleconsole-applicationtui

提问by evamvid

How can I make a console GUI (more appropriately called TUI) ?

如何制作控制台 GUI(更恰当地称为 TUI)?

It's important to note that I will be changing the text in some of the spots, and this is why I can't have it just print to the screen. It would be fine to use other modules, but I'd prefer not to have to. Here's an ASCII mockup of what it would look like:

重要的是要注意,我将更改某些地方的文本,这就是为什么我不能将其打印到屏幕上的原因。使用其他模块会很好,但我不想必须这样做。这是它的外观的 ASCII 模型:

           ********************************************
           *                                          *
           *                                          *         
           *                                          * 
           *      There are 8 seconds left.           *
           *                                          *         
           *                                          * 
           *                                          *
           *      The script has run 8 times          *         
           *                                          * 
           *                                          *
           *                                          *         
           *                                          * 
           ********************************************

I would need to be able to update the timer and the number of iterations dynamically.

我需要能够动态更新计时器和迭代次数。

I know how to write over the last printed line using the carriage return. But I can't use that on both lined.

我知道如何使用回车符覆盖最后打印的行。但我不能在两个内衬上使用它。

采纳答案by Matt Woelk

Try using the cursesmodule.

尝试使用curses模块。

Here's an introduction.

这是一个介绍

回答by bodolsog

There is some libraries for that:

有一些图书馆: