Are there any packages that offer this sort of thing? I'd prefer ones
from the Debian repositories but that's not absolutely necessary.
If that's too tied to specific systems for your taste,
why not cook up a library that smooths out those wrinkles?
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.
It might also be possible/useful to use the mouse for this.
This is what I was going to suggest. Rich is super easy to use.
On 14/01/2025 00:20, Grant Edwards via Python-list wrote:
On 2025-01-13, Alan Gauld via Python-list <python-list@python.org> wrote:
All of that is possible in curses, you just have to code it.
All of that is easy with curses in C. Unfortunately, the high level "panel" and "menu" curses subystems that make it easy aren't included
in the Python curses API,
panel is included. Just import curses.panel.
menu unfortunately isn't but it's not difficult to roll
your own by creating a window with a list of options, provided
you don't try to get too fancy(submenus etc).
Yes, thanks all, maybe just straightforward curses is the way to go.
Looking at some of the 'cleverer' ones they end up looking remarkably
like GUI code, in which case I might as well use a GUI. I have written
a (fairly simple) Gtk based python program, I was just trying to avoid
all the GUI overheads for a little new project.
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 onesMaybe pythondialog could be useful for this. I've never used it so I
from the Debian repositories but that's not absolutely necessary.
Alan Gauld <learn2program@gmail.com> writes:I haven't followed this whole thread, but rich (low-level) and textual (higher-level) are designed for this - part of the same project family -
On 15/01/2025 00:41, Keith Thompson via Python-list wrote:
Alan Gauld <learn2program@gmail.com> writes:
On 11/01/2025 14:28, Chris Green via Python-list wrote:
I'm looking for Python packages that can help with text mode input,
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 454 |
Nodes: | 16 (2 / 14) |
Uptime: | 31:23:53 |
Calls: | 9,286 |
Calls today: | 1 |
Files: | 13,515 |
Messages: | 6,073,079 |