Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #168: le0: no carrier: transceiver cable problem?


comp / comp.lang.python / Re: Tools to help with text mode (i.e. non-GUI) input

SubjectAuthor
* Tools to help with text mode (i.e. non-GUI) inputChris Green
+* Re: Tools to help with text mode (i.e. non-GUI) inputStefan Ram
|`* Re: Tools to help with text mode (i.e. non-GUI) inputStefan Ram
| `* Re: Tools to help with text mode (i.e. non-GUI) inputrustbuckett
|  `- Re: Tools to help with text mode (i.e. non-GUI) inputChris Green
+- Re: Tools to help with text mode (i.e. non-GUI) inputdn
`- Re: Tools to help with text mode (i.e. non-GUI) inputRoel Schroeven

1
Subject: Tools to help with text mode (i.e. non-GUI) input
From: Chris Green
Newsgroups: comp.lang.python
Date: Sat, 11 Jan 2025 14:28 UTC
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Tools to help with text mode (i.e. non-GUI) input
Date: Sat, 11 Jan 2025 14:28:49 +0000
Lines: 36
Message-ID: <1qba5l-7rcr.ln1@q957.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net xPI7Q60nnXNrEK/0ISRQ6Ar+1a1IwpWblSTRNeP0JCuA9Uux8=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:yZ07c6I3fzkF+F7zAD5bL5sWLGc= sha256:cAiba1W97yw1dioSjkrU4DKPetP49IDuSOf0LaEMxBQ=
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-28-amd64 (x86_64))
View all headers

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.

--
Chris Green
·

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Sat, 11 Jan 2025 15:13 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: 11 Jan 2025 15:13:57 GMT
Organization: Stefan Ram
Lines: 140
Expires: 1 Jan 2026 11:59:58 GMT
Message-ID: <non-GUI-20250111161021@ram.dialup.fu-berlin.de>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de uPqqrRNE1lnUJbsYOOCRvw5u0kcu1pWh0Q3ojaVcjK3hr/
Cancel-Lock: sha1:U5o7IWop12tRzoGwT8uckdgkmE0= sha256:nbt+9XY+Cc/VIf0XTNDhgPmjP2wzBMrSyrSUGiT/4M8=
X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Chris Green <cl@isbd.net> wrote or quoted:
>Are there any packages that offer this sort of thing? I'd prefer ones
>from the Debian repositories but that's not absolutely necessary.

So, in my humble opinion, it's a no-brainer to split this into two
camps and draw a line between Linux and Windows.

On Linux, you're going to wanna roll with curses. See [1] below.

For Windows, whip up your own terminal using tkinter (Yeah,
tkinter's a GUI library, no doubt! But in this case, it's just
being used to mimic a terminal.) as your secret sauce. See [2].

If that's too tied to specific systems for your taste,
why not cook up a library that smooths out those wrinkles?

The following drafts still contain bugs, but might convey
the idea.

[1]

import curses

def main(stdscr):
# Clear screen and hide cursor
stdscr.clear()
curses.curs_set(1)

# Display prompt
stdscr.addstr(0, 0, "Color? ")

# Pre-fill with "red"
default_text = "red"
stdscr.addstr(0, 7, default_text)

curses.echo() # Enable echo of characters
curses.cbreak() # React to keys instantly without Enter key

# Initialize cursor position
cursor_x = 7 + len(default_text)
current_text = default_text

while True:
stdscr.move(0, cursor_x)
ch = stdscr.getch()

if ch == ord('\n'): # Enter key
break
elif ch in (curses.KEY_BACKSPACE, 127): # Backspace
if cursor_x > 7:
cursor_x -= 1
current_text = current_text[:cursor_x-7] + current_text[cursor_x-6:]
stdscr.delch(0, cursor_x)
elif ch == curses.KEY_LEFT:
if cursor_x > 7:
cursor_x -= 1
elif ch == curses.KEY_RIGHT:
if cursor_x < 7 + len(current_text):
cursor_x += 1
elif 32 <= ch <= 126: # Printable characters
current_text = current_text[:cursor_x-7] + chr(ch) + current_text[cursor_x-7:]
stdscr.insch(0, cursor_x, ch)
cursor_x += 1

stdscr.refresh()

# Clear screen
stdscr.clear()

# Display result
stdscr.addstr(0, 0, f"You entered: {current_text}")
stdscr.refresh()
stdscr.getch()

if __name__ == "__main__":
curses.wrapper(main)

[2]

import tkinter as tk
from tkinter import simpledialog

class ColorQueryApp:
def __init__(self, master):
self.master = master
master.title("Color Query")

# Create the Text widget
self.text_field = tk.Text(master, height=10, width=40)
self.text_field.pack(padx=10, pady=10)

# Create a button to add new color queries
self.add_button = tk.Button(master, text="Add Color Query", command=self.add_color_query)
self.add_button.pack(pady=5)

# Bind the Return key event
self.text_field.bind('<Return>', self.show_color_dialog)

def add_color_query(self):
# Insert a new line if the Text widget is not empty
if self.text_field.index('end-1c') != '1.0':
self.text_field.insert('end', '\n')

# Insert the new color query line
query_line = "Color? red"
self.text_field.insert('end', query_line)

# Move the cursor to the end of the new line
self.text_field.mark_set('insert', f'{self.text_field.index("end-1c")}')

# Bind the key events
self.text_field.bind('<Key>', self.check_editing)

def check_editing(self, event):
# Allow all keystrokes if cursor is in editable area
if self.text_field.compare('insert', '>=', 'insert linestart+7c'):
return

# Prevent editing in the "Color? " area
if event.keysym in ['BackSpace', 'Delete'] or len(event.char) > 0:
return 'break'

def show_color_dialog(self, event):
# Get the current line
current_line = self.text_field.get("insert linestart", "insert lineend")

# Extract the color
color = current_line[7:].strip()

# Show a dialog with the entered color
simpledialog.messagebox.showinfo("Entered Color", f"You entered: {color}")

# Prevent the default newline behavior
return 'break'

root = tk.Tk()
app = ColorQueryApp(root)
root.mainloop()

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Sat, 11 Jan 2025 19:31 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: 11 Jan 2025 19:31:54 GMT
Organization: Stefan Ram
Lines: 23
Expires: 1 Jan 2026 11:59:58 GMT
Message-ID: <libraries-20250111203128@ram.dialup.fu-berlin.de>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu> <non-GUI-20250111161021@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 1kBm0t9s50Ou1pBGNx6KVAysOv/A73h6E2k2fEbVYhZiy0
Cancel-Lock: sha1:q7nX/1tppMD6/Rqx2qYYIeg9w0U= sha256:qulIkuGvWhuz2Tno8KyDOcp7wAh4eQxlkPQI++6QGt0=
X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>If that's too tied to specific systems for your taste,
>why not cook up a library that smooths out those wrinkles?

Or, if you want to use a library instead of writing one, check out:

Textual – An async-powered terminal application framework for Python

Textual was built on top of

Rich - a terminal application renderer (not using async) and toolkit

There's also:

py_cui: library for creating CUI/TUI interfaces with pre-built widgets

PyTermGUI: terminal UI library

Python Prompt Toolkit: library for command line applications

Urwid: a console user interface library for Python

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: dn
Newsgroups: comp.lang.python
Organization: DWM
Date: Sun, 12 Jan 2025 00:49 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: Sun, 12 Jan 2025 13:49:03 +1300
Organization: DWM
Lines: 42
Message-ID: <mailman.62.1736643524.2912.python-list@python.org>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
<b36486f4-0c7a-4d39-bbe8-7166c17ea84f@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de KFBidhXIUyPA8cSnliVg0Ad99ZG+2dsUposBdYZbxL0Q==
Cancel-Lock: sha1:Ie9xSMHnjsUAGRyeZY1qKOKErKA= sha256:jsILJsE+e0VKWosokRndw0tmCzY1UKJ1Qy/B0aQblPQ=
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=danceswithmice.info header.i=@danceswithmice.info
header.b=U8tPKbwa; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.020
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'entering': 0.05; 'else.':
0.07; 'hitting': 0.07; '=dn': 0.09; 'characters,': 0.09; 'debian':
0.09; 'from:addr:danceswithmice.info': 0.09;
'from:addr:pythonlist': 0.09; 'repositories': 0.09; 'subject:GUI':
0.09; 'terminal': 0.09; 'url:master': 0.09; 'bash': 0.16;
'black,': 0.16; 'colours': 0.16; 'displayed': 0.16; 'input,':
0.16; 'message-id:@DancesWithMice.info': 0.16; 'received:cloud':
0.16; 'received:rangi.cloud': 0.16; 'wrote:': 0.16; 'python':
0.16; 'values': 0.17; 'to:addr:python-list': 0.20; 'input': 0.21;
'i.e.': 0.22; 'maybe': 0.22; 'command': 0.23; "i'd": 0.24;
'chris': 0.28; 'header:User-Agent:1': 0.30; 'packages': 0.31;
'default': 0.31; 'program': 0.32; 'python-list': 0.32; 'window':
0.32; 'header:Organization:1': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'header:In-Reply-To:1': 0.34; 'running': 0.35;
'runs': 0.35; 'url:)': 0.35; 'this.': 0.35; 'change': 0.36;
'presented': 0.37; 'could': 0.37; 'received:192.168': 0.37; 'way':
0.38; 'list': 0.39; 'use': 0.39; "that's": 0.39; 'text': 0.39;
'prompt': 0.39; 'something': 0.40; 'want': 0.40; 'initial': 0.61;
'above': 0.62; 'mode': 0.62; 'key': 0.64; 'down': 0.64; 'url-
ip:104.16/16': 0.65; 'accept': 0.67; 'choose': 0.68; 'offer':
0.70; 'ability': 0.71; 'addition': 0.71; 'subject:. ': 0.73;
'absolutely': 0.84; 'from.': 0.84; 'mouse': 0.84; 'narrow': 0.84;
'subject:Tools': 0.84; 'subject:input': 0.84; 'subject:text':
0.84; 'thing?': 0.84; 'return.': 0.91; 'green': 0.96
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 7A53B43E1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1736642950;
bh=HUlTntD94Wnf3nJS/gTjuR75l89Bmi547pjn9E8J4Pw=;
h=Date:From:Subject:To:References:In-Reply-To:From;
b=U8tPKbwavFZonGR/CvgT6/kmnsx+1xiCB8JIldZALCFJT1+Q2PDcYOEBIPfjsJFXn
vh5hZdoikUTx9nbMGFWMQGzDYxEUec0rgXGYH0jSyM9S8QstONWeXnrWPuscwW5PkU
4bZPCnM++QGorz09b99z64QrhZPTwJrJC9piwjhMeo2M7oFbbC8u1hsZfVyEsSVl68
vnjXBqAjOSFpOUyN7ngld/2zcJgzITmbVlr7xtRxifCKAPVeT9Ano+vhxmcj3xUOBO
XVwziIiH18sI/quNBPAbNL62omw0hRpqExbhBzR1764CyTjCgP/7ebgIG97wMC5r/d
3HENm3iGK+Urg==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <1qba5l-7rcr.ln1@q957.zbmc.eu>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <b36486f4-0c7a-4d39-bbe8-7166c17ea84f@DancesWithMice.info>
X-Mailman-Original-References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
View all headers

On 12/01/25 03:28, Chris Green via Python-list wrote:
> 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.

There must be more choices/combinations of packages to do this. Maybe a
good place to start is the Python Prompt Toolkit
(https://python-prompt-toolkit.readthedocs.io/en/master/)

--
Regards,
=dn

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: rustbuckett@nope.com
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sun, 12 Jan 2025 02:49 UTC
References: 1 2 3
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rustbuckett@nope.com
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: Sat, 11 Jan 2025 21:49:39 -0500
Organization: A noiseless patient Spider
Lines: 2
Message-ID: <87jzb04ugs.fsf@pm.me>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
<non-GUI-20250111161021@ram.dialup.fu-berlin.de>
<libraries-20250111203128@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 12 Jan 2025 03:49:41 +0100 (CET)
Injection-Info: dont-email.me; posting-host="1594b86c059ee9fccaecd8e5712127dc";
logging-data="936692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+njz1i+jVU8HHjoa8r+hDah5FA3GXZEgY="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:5NJLQ/nWsYT/mUtsq7i6LNmYKWw=
sha1:VusldBJN4n9QOUZ0xyBLP03lLe4=
View all headers

This is what I was going to suggest. Rich is super easy to use.

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: Chris Green
Newsgroups: comp.lang.python
Date: Sun, 12 Jan 2025 12:03 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: Sun, 12 Jan 2025 12:03:37 +0000
Lines: 9
Message-ID: <plnc5l-l9ft.ln1@q957.zbmc.eu>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu> <non-GUI-20250111161021@ram.dialup.fu-berlin.de> <libraries-20250111203128@ram.dialup.fu-berlin.de> <87jzb04ugs.fsf@pm.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net cSHWJJXJsfqPL+RlLI/j/ArFc3k0UTMZ39hXMImCek6Jb9YKg=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:uoLY8N855pVXERMsW+cwqtO097I= sha256:L0BZP7i5IoiUw8meoHXpK3/6tCj6JYF+Xv3pI7WaoLs=
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-28-amd64 (x86_64))
View all headers

rustbuckett@nope.com wrote:
>
> This is what I was going to suggest. Rich is super easy to use.

OK, thanks, Rich is on my shortlist then.

--
Chris Green
·

Subject: Re: Tools to help with text mode (i.e. non-GUI) input
From: Roel Schroeven
Newsgroups: comp.lang.python
Date: Thu, 16 Jan 2025 09:09 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: Tools to help with text mode (i.e. non-GUI) input
Date: Thu, 16 Jan 2025 10:09:36 +0100
Lines: 49
Message-ID: <mailman.82.1737018581.2912.python-list@python.org>
References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
<bee21602-c16e-47ca-90b5-7f663e2317ad@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de stXFOwDkGlxkOVtawqRcTQt6GZaEmbRdTHMuticWpBtw==
Cancel-Lock: sha1:XFSQGl6RFhMOheABDLOL8aNI46w= sha256:mxPn9248ypzsyq3bsRWcjQIqUR9BKMA3/42rXSgcxFM=
Return-Path: <roel@roelschroeven.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=roelschroeven.net header.i=@roelschroeven.net
header.b=AlE4s11F; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'looks': 0.02; 'entering':
0.05; 'pypi': 0.05; 'else.': 0.07; 'hitting': 0.07; 'characters,':
0.09; 'debian': 0.09; 'describe': 0.09; 'page:': 0.09;
'repositories': 0.09; 'subject:GUI': 0.09; 'terminal': 0.09;
'bash': 0.16; 'black,': 0.16; 'colours': 0.16; 'displayed': 0.16;
'input,': 0.16; 'received:10.202': 0.16; 'received:10.202.2':
0.16; 'received:10.202.2.163': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'schreef': 0.16; 'sight':
0.16; 'url:doc': 0.16; 'url:project': 0.16; 'url:pypi': 0.16;
'url:widgets': 0.16; 'python': 0.16; 'values': 0.17; "can't":
0.17; 'to:addr:python-list': 0.20; 'input': 0.21; "i've": 0.22;
'i.e.': 0.22; 'maybe': 0.22; 'command': 0.23; "i'd": 0.24;
'seems': 0.26; 'chris': 0.28; 'header:User-Agent:1': 0.30;
'packages': 0.31; 'seem': 0.31; 'default': 0.31; 'program': 0.32;
"doesn't": 0.32; 'window': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'header:In-Reply-To:1': 0.34; 'running': 0.35;
'runs': 0.35; 'this.': 0.35; 'really': 0.36; 'change': 0.36;
'presented': 0.37; 'could': 0.37; 'way': 0.38; 'url-
ip:151.101.0.223/32': 0.38; 'url-ip:151.101.128.223/32': 0.38;
'url-ip:151.101.192.223/32': 0.38; 'url-ip:151.101.64.223/32':
0.38; 'list': 0.39; 'use': 0.39; "that's": 0.39; 'least': 0.39;
'text': 0.39; 'prompt': 0.39; 'happen': 0.40; 'something': 0.40;
'want': 0.40; 'tell': 0.60; 'initial': 0.61; 'above': 0.62;
'mode': 0.62; 'everything': 0.63; 'key': 0.64; 'your': 0.64;
'down': 0.64; 'accept': 0.67; 'choose': 0.68; 'offer': 0.70;
'ability': 0.71; 'addition': 0.71; 'subject:. ': 0.73;
'absolutely': 0.84; 'from.': 0.84; 'maria': 0.84; 'narrow': 0.84;
'subject:Tools': 0.84; 'subject:input': 0.84; 'subject:text':
0.84; 'thing?': 0.84; 'url:sourceforge': 0.84; 'beauty': 0.91;
'return.': 0.91; 'received:103': 0.91; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to; s=fm1; t=1737018578; x=1737104978; bh=5/LQzzq6KsEGNVM002D+d
tTtz46uwmLdbZWRxTx4jw4=; b=AlE4s11FomG2IS38hK2FwOEQ54ZqwDqde/oJF
CWZWqY7UJx44ZzrCUeiGrWDyGHSRR5diEyNfCflzvEr9T6m2Xi+6Qvp6Lzf05BcZ
8kUirF9QawDczk+ZaCGhGxkXkvzXwseYnlNNO1KeSUlX8M+7nO+fjYiPmRDw08q8
/iTG6Bw3W+c/F2gRGrwk64yB8+A8iwGdn24P2gv5lNCGVU6CK5A4nJ0kHkOvJqaU
KEQO7Z0/IJ4UKYOSC1UcGNTD1GAGu2M2jCbHG5msuNYVJiQ3s3a3sMta1rL9a55H
kKGBKI4nN/QhAoydtGymEu4vUbZVlVbGQAKQ/Wmpev28KcNQA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender
:x-me-sender:x-sasl-enc; s=fm2; t=1737018578; x=1737104978; bh=5
/LQzzq6KsEGNVM002D+dtTtz46uwmLdbZWRxTx4jw4=; b=CJ8T0nqK6yhntLTsE
HEY01hX+z3GH0VQk/HnKakCSV9+Ydhb9M4mf5vHQziPmU7KC0mmeswFLG4kcVjmO
bC14K1kCjztSqZDx7jRRi/lmrhxYiN6F86xS0fLSr5HwxJ1cVbGcPdcuGOdHimaq
eOTEwzx5IjbG6o/KYBHvvj4f5skv74QZ9IJXG9zbK1zc3L3op9V8SZwNY5b7vGU1
MNWl0uvAtveVbtKL+KirbGYYk9naOfrOaFO5uiZznjtq4Tu3do3RRLylpD5GilX8
qRtuwJ7sCYvEtD6u5A99PI/kSOZns6dogFGLOHgj2x7fdMLpM5bm5SUn+q/KqpiD
fAbTw==
X-ME-Sender: <xms:0syIZ6jy4sxg16L6nJf1imcaZxFsIizapI6vbQXcbtIEIX0VjZ7VEg>
<xme:0syIZ7Bdes1pv7E9YIvx6oStqOJcks_jfuOiY9muL-NQeUP3bQPj1jZS0JclACMic
rmldif1coE1>
X-ME-Received: <xmr:0syIZyFc5mK-g8izGohZRTCvDh77cfTnVI--xKsm6rfb3H81q_TGE2rePaS_7ywlNQ8Id0QGKIgm6GfWR6HMuRS9cz5f2qocBAJ58AZb2slvthc>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeiudcutefuodetggdotefrodftvfcurf
hrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffrtefo
kffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfh
fhjggtgfesthejredttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghnuceo
rhhovghlsehrohgvlhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrhhnpe
ejuefhgfegtdekjeehgfffteeileegveeuleeutdeitddtjeefjefgfeekjeefvdenucff
ohhmrghinhepshhouhhrtggvfhhorhhgvgdrihhopdhphihpihdrohhrghenucevlhhush
htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlhesrhhovghl
shgthhhrohgvvhgvnhdrnhgvthdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtph
houhhtpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
X-ME-Proxy: <xmx:0syIZzRMKuTaE-lEKK7_OC4Jx3wTinC3sWq-jPIVuXlgRx_wI-faLg>
<xmx:0syIZ3zurLoYzMTMVm9OygXL7S924I5Jae8kAd9cPFKqXsQSgWmgvQ>
<xmx:0syIZx6PG736bVjWEFvG2HEDTYgoVfYLFxHLGioVShKgp8-FSwgVjw>
<xmx:0syIZ0x1lq0YTpHwiiLRKbVNqttK_shtGjbI01hOUYryKC3Bqir_OQ>
<xmx:0syIZwoqoxkuWw17x4RmiJc4QCQTOeomQJqtmN3wBklSV9BL6WJT6s8k>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: nl, en-US
In-Reply-To: <1qba5l-7rcr.ln1@q957.zbmc.eu>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <bee21602-c16e-47ca-90b5-7f663e2317ad@roelschroeven.net>
X-Mailman-Original-References: <1qba5l-7rcr.ln1@q957.zbmc.eu>
View all headers

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

1

rocksolid light 0.9.8
clearnet tor