Deutsch   English   Français   Italiano  
<mailman.68.1736808383.2912.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: Alan Gauld <learn2program@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: Tools to help with text mode (i.e. non-GUI) input
Date: Mon, 13 Jan 2025 22:46:19 +0000
Lines: 80
Message-ID: <mailman.68.1736808383.2912.python-list@python.org>
References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
 <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk>
Reply-To: alan.gauld@yahoo.co.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de QINuk5elq/F4LcJi7WPR5wSaLLGguGcilDwlUx4Paf+g==
Cancel-Lock: sha1:sE6UXyKKwa24KfbDwXjePIJrcyQ= sha256:5pT3jh7Fmwdb9sFwID0u+DQsY+FAq0v23OfhNlSZD3w=
Return-Path: <learn2program@gmail.com>
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=gmail.com header.i=@gmail.com header.b=XJ04KSSR;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.049
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'entering': 0.05; 'gui':
 0.05; 'python:': 0.05; 'areas.': 0.07; 'else.': 0.07; 'hitting':
 0.07; 'characters,': 0.09; 'debian': 0.09; 'repositories': 0.09;
 'subject:GUI': 0.09; '*nix': 0.16; 'black,': 0.16; 'colour': 0.16;
 'colours': 0.16; 'dialogs,': 0.16; 'displayed': 0.16; 'flickr':
 0.16; 'from:name:alan gauld': 0.16; 'input,': 0.16; 'kindle':
 0.16; 'message-id:@yahoo.co.uk': 0.16; 'option.': 0.16; 'photo-
 blog': 0.16; 'received:mail-ej1-x635.google.com': 0.16; 'reply-
 to:addr:alan.gauld': 0.16; 'sounds': 0.16; 'toolkit.': 0.16; 'url-
 ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16; 'url-
 ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
 'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'wrote:':
 0.16; 'python': 0.16; 'values': 0.17; 'url:amazon': 0.19; 'to:addr
 :python-list': 0.20; 'input': 0.21; 'i.e.': 0.22; 'maybe': 0.22;
 'tools.': 0.22; 'code': 0.23; "i'd": 0.24; 'to:name:python-
 list@python.org': 0.24; 'skip:- 10': 0.25; 'library': 0.26;
 'party': 0.26; 'url-ip:18.239.70.223/32': 0.26; 'url-
 ip:18.239.70/24': 0.26; 'chris': 0.28; 'etc': 0.28; 'environment':
 0.29; 'header:User-Agent:1': 0.30; 'packages': 0.31; 'default':
 0.31; 'program': 0.32; '---------': 0.32; 'do.': 0.32;
 'programmers': 0.32; 'python-list': 0.32; 'but': 0.32;
 'received:192.168.1': 0.32; "i'm": 0.33; 'there': 0.33; 'header
 :In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'package':
 0.34; 'from:addr:gmail.com': 0.34; 'book': 0.35; 'this.': 0.35;
 'really': 0.36; 'display': 0.36; 'change': 0.36; 'those': 0.36;
 'couple': 0.37; 'presented': 0.37; 'using': 0.37; 'could': 0.37;
 'author': 0.37; 'received:192.168': 0.37; 'way': 0.38; 'list':
 0.39; 'use': 0.39; "that's": 0.39; 'text': 0.39; 'enough': 0.39;
 'prompt': 0.39; 'wrote': 0.39; 'alan': 0.40; 'forms': 0.40;
 'learn': 0.40; 'something': 0.40; 'want': 0.40; 'initial': 0.61;
 'url-ip:18.239/16': 0.61; 'above': 0.62; 'mode': 0.62; 'follow':
 0.62; 'online': 0.63; 'key': 0.64; 'down': 0.64; 'top': 0.65;
 'documents': 0.65; 'areas': 0.67; 'accept': 0.67; 'choose': 0.68;
 'site': 0.68; 'etc,': 0.69; 'reply-to:addr:yahoo.co.uk': 0.69;
 'strength': 0.69; 'url:author': 0.69; 'url:us': 0.69; 'within':
 0.69; 'offer': 0.70; 'ability': 0.71; 'virtual': 0.71; 'addition':
 0.71; 'url-ip:18/8': 0.72; 'subject:. ': 0.73; 'easy': 0.74;
 'tools': 0.74; 'reply-to:no real name:2**0': 0.78; 'header:Reply-
 To:1': 0.79; 'url-ip:44/8': 0.81; 'position': 0.81; 'absolutely':
 0.84; 'characters': 0.84; 'choice,': 0.84; 'easy.': 0.84; 'from.':
 0.84; 'mouse': 0.84; 'narrow': 0.84; 'pop-up': 0.84;
 'subject:Tools': 0.84; 'subject:input': 0.84; 'subject:text':
 0.84; 'thing?': 0.84; 'pop': 0.91; 'return.': 0.91; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1736808380; x=1737413180; darn=python.org;
 h=content-transfer-encoding:in-reply-to:to:references:reply-to
 :content-language:subject:user-agent:mime-version:date:message-id
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=N1OTOZWXGvNSP+n73e34vd8HwG+ElUrQxjieB40v1Gk=;
 b=XJ04KSSRgz9F49UckdTaMrtWBeYuGccgF+47yQywHmzoO3ncMCPN2DHntaFNlOoggA
 Aog6Hr+uBHLG5Tlnqdp5+sWEfJBxk9k/gZ1wKCx5fOjgTfc4tJ7t/d6ucjAXMgyvJFsv
 zN066Hw7xABvoT4EZcelyvYyVTcUZHgD1lQe/zEchDIzB7cVe4bSxZDnZkz+Ad0kYuZB
 mTkkhaAwqKYWsREWtVlfN+awBnybTy9N45WqK+uxw3Xc589ZASVivDBMQJFc22o5XByC
 JDtjEOYLHdlYbsrUNdyk51eHUd1Wo7UBUm74NqYvI5hzuGTtjsLVYEP8xNIZ1eUOQJDP
 RX+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1736808380; x=1737413180;
 h=content-transfer-encoding:in-reply-to:to:references:reply-to
 :content-language:subject:user-agent:mime-version:date:message-id
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=N1OTOZWXGvNSP+n73e34vd8HwG+ElUrQxjieB40v1Gk=;
 b=NW17G2b0lQCvVvlMEGBKfo7xuEz4GN7hn+9geDh0p9nQpe3w7wzEhb6PVd25hJ2qND
 8hbt5lyjd7HBQagxpJplKFDhX3fIoqBA/JoyrxaF2zTOb/MbtteXQUsjGO0iPR7PFwhr
 qAIdnHpTMVod/CKSC3PAS4eMBDMm1bJmerdO6Yl5UrMbOApsEFcNh4Hx/glhCVK6Erpk
 LAJEi//aytJn5F74YpjMvM0TkqDojpP0bOgyKBLXLSa2ttNUoidDj1n0KZqX900hgWix
 hHfpUI3LwHjE8uxKrQgTN++yLyzawKoGU5iIKTAZxxjbFGI9bi618dhLyATYTIFrIpvW
 oKkQ==
X-Gm-Message-State: AOJu0YxjVcOLkVGLAVN9K5hGjmPJei4QdE5A54VhSd9jHxGbA+L3CqDE
 mx99AG9f9sNf1WfWAFzLVNMufzw4AzqsDiZi4O01i5qxTHEPQUSTyG+LSQ==
X-Gm-Gg: ASbGnctQRl8v4pYCaVzs0xAld5S/Db5BiCRwKnERypkgUzcTir3A+boO9e2MtUZgUrz
 44UnFUcXIPlnBDPrZBmv7pF8rQomf6flo1SIFWmeQO4HcIMKwHINcbkLPTjXefRnjk03Mjuu6Ql
 nGH+tiAAIiYe8oXDKM60nLl7ZME5QVnmG3XkKTcbWR1qJ4bxnIQ30kemmwRVeeVgPkL2hao+sK/
 Gthf7U2PhzePn+zj9R2oiol8W5lMk2pMEPHmBMT7UbhO77qkT/fcwE9Fh99WfHa9lXpsGkQBg==
X-Google-Smtp-Source: AGHT+IHzi12r1mDAC6oQY23Gt4IYvXjW0nn0lB9c6+ceX1/4Ru8YD0LEBhLPvCQ39Fr+wSWfuvTGcA==
X-Received: by 2002:a17:907:31c4:b0:ab3:2530:dc89 with SMTP id
 a640c23a62f3a-ab32530e6f4mr350346066b.20.1736808380246; 
 Mon, 13 Jan 2025 14:46:20 -0800 (PST)
X-Google-Original-From: Alan Gauld <alan.gauld@yahoo.co.uk>
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
X-Forwarded-Message-Id: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
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: <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk>
X-Mailman-Original-References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
Bytes: 10437

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,

The standard package for this is curses which comes as part
of the standard library on *nix distros.

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

The default value is easy. The list of values sounds like a pop-up menu.
Ofr you can just offer a prompt with a list in it that the user
picks(maybe by number?) Its really a programmers choice, curses provides
the tools to display it however you choose. (Yu might also find the
dialog third party package useful for displaying text mode dialog boxes)

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

All of that is possible in curses, you just have to code it.

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

Again that's easy enough to do. Or you could pop up a menu and
allow the user to cursor up/dowmn (or use the mouse) to select
an option.

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

Again that's more about the programmer's use of the tools. curses
allows you to display the characters wherever/however you want
on screen.

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

curses dores all you want but you need to do all the logic, its not as
simple as using a GUI toolkit. dialog sits on top of curses and provides
a more GUI like experiece.

urwin is another toolkit for text mode but it is more of a pseudo GUI
environment with a menu-bar, dialogs, forms etc etc. Curses is about
mapping areas of the screen(windows) and displaying text within those
areas. You can control colour and strength etc, move things around,
hide/show areas, position the cursor anywhere on screen. You can even
create huge virtual screens and use the visible screen as a viewport
into that(think like a big spreadsheet)

There are a couple of Howto type documents online

Shameless Plug:
---------
I wrote a short kindle book on curses with python:
https://kdp.amazon.com/amazon-dp-action/us/dualbookshelf.marketplacelink/B091B85B77
-------------

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

========== REMAINDER OF ARTICLE TRUNCATED ==========