a Python3 module offering a Command-Line User Interface
from TermClui import *
chosen = choose("A Title", a_list); # single choice
chosen = choose("A Title", a_list, multichoice=True) # multiple choice
x = choose("Which ?\n(Mouse, or Arrow-keys and Return)", w) # multi-line q
x = choose("Which ?\n"+help_text(), w) # built-in help_text
confirm(text) and do_something()
answer = ask(question)
answer = ask(question, suggestion)
password = ask_password("Enter password : ")
filename = ask_filename("Which file ?")
newtext = edit(title, oldtext)
view(title, text) # if title is not a filename
view(textfile) # if textfile _is_ a filename
edit(choose("Edit which file ?", list_of_files))
file = select_file(Readable=True, TopDir="/home", FPat="*.html")
files = select_file(Chdir=False, multichoice=True, FPat="*.mp3")
TermClui.py offers a high-level user interface to give the user
of command-line applications a consistent "look and feel". Its
metaphor for the computer is as a human-like conversation-partner;
as each question/response is completed, it is summarised to one line
and remains on screen, so that the history of the session gradually
accumulates on the screen, available for review or for cut/paste.
This user-interface can be intermixed with standard applications
which write to STDOUT or STDERR, such as make, pgp, rcs etc.
For the user, choose() uses either (since 1.50) the mouse; or arrow
keys (or hjkl) and Return or q; also SpaceBar for multiple choices.
confirm() expects y, Y, n or N. In general, ctrl-L redraws the
(currently active bit of the) screen. edit() and view() use the
default EDITOR and PAGER if possible. Window-size-changes are handled,
though the screen only gets redrawn after the next keystroke (e.g. ctrl-L)
choose(), ask() and confirm() all accept multi-line questions:
the first line should be the core question (typically it will
end in a question-mark) and will remain on the screen together
with the user's answer. The subsequent lines appear beneath the
dialogue, and will disappear when the user has given the answer.
TermClui.py does not use curses (a whole-of-screen interface), it uses
a small and portable subset of vt100 sequences. Also (since 1.50) the
SET_ANY_EVENT_MOUSE and kmous (terminfo) sequences, which are supported
by all xterm, rxvt, konsole, screen, linux, gnome and putty terminals.
Since version 1.60, a speaking interface is provided for the visually
impaired user; it employs eflite or espeak. Speech is turned on
if the CLUI_SPEAK environment variable is set to any non-empty string.
Since version 1.62, if speakup is running, it is silenced while
TermClui runs, and then restored. Because TermClui's metaphor for
the computer is a human-like conversation-partner, this works very
naturally. The application needs no modification.
Download TermClui.py from www.pjb.com.au/midi/free/TermClui.py or
and put it in your PYTHONPATH. TermClui.py depends on Python3.
TermClui.py is a translation into Python3 of the Perl CPAN Modules
Term::Clui and Term::Clui::FileSelect. This is version 1.70
|SpeakMode = set()|
VERSION = '1.70'