Op 11/01/2025 om 15:28 schreef Chris Green via Python-list:
I'm looking for Python packages that can help with text mode input,
i.e. for use with non-GUI programs that one runs from the command
prompt in a terminal window running a bash shell or some such.

What I'm specifically after is a way to provide a default value that
can be accepted or changed easily and also a way to provide a number
of different values to choose from.

I.e. for the default sort of input one might see:-

     Colour? red

Hitting return would return 'red' to the program but you could also
backspace over the 'red' and enter something else.  Maybe even better
would be that the 'red' disappears as soon as you hit any key other
than return.


For the select a value type of input I want something like the above
but hitting (say) arrow up and arrow down would change the value
displayed by the 'Colour?' prompt and hitting return would accept the
chosen value.  In addition I want the ability to narrow down the list
by entering one or more initial characters, so if you enter 'b' at the
Colour? prompt the list of values presented would only include colours
starting with 'b' (beige, blue, black, etc.)


Are there any packages that offer this sort of thing? I'd prefer ones
from the Debian repositories but that's not absolutely necessary.
Maybe pythondialog could be useful for this. I've never used it so I can't really tell if it will fit your requirements, but at least it seems worth a look. It looks like it supports text input with a default value (https://pythondialog.sourceforge.io/doc/widgets.html#single-line-input-fields). The other thing you describe is, if I understand correctly, an input with predefined values but also the ability to enter a custom value. At first sight that doesn't seem to be provided.

PyPI page: https://pypi.org/project/pythondialog/
Home page: https://pythondialog.sourceforge.io/

--
"Let everything happen to you
Beauty and terror
Just keep going
No feeling is final"
        -- Rainer Maria Rilke

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to