Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Terminal/Text UI (TUI) library [closed]

How can I make a console GUI (more appropriately called 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:

           ********************************************
           *                                          *
           *                                          *         
           *                                          * 
           *      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.

like image 293
evamvid Avatar asked Mar 14 '14 00:03

evamvid


People also ask

What is Tui in Python?

Moya: Open source web development platform built with Python. Building Rich terminal dashboards: Will's blog. Textual: A TUI (Text User Interface) framework for Python inspired by modern web development. The 2021 Python Language Summit: Making CPython Faster.

What is Textual Python?

Textual is a TUI (Text User Interface) framework for Python inspired by modern web development. Currently a work in progress, but usable by brave souls who don't mind some API instability between updates. Textual currently runs on MacOS / Linux only. Windows support is in the pipeline.


2 Answers

There is some libraries for that:

  • curses which is python frontend to ncurses (tutorial)
  • urwid (tutorial)
  • npyscreen
  • python-prompt-toolkit
  • curtsies
  • asciimatics
  • picotui
like image 169
Paweł BB Drozd Avatar answered Sep 22 '22 09:09

Paweł BB Drozd


Try using the curses module.

Here's an introduction.

like image 30
Matt Woelk Avatar answered Sep 22 '22 09:09

Matt Woelk