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

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

Path: ...!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: Fri, 17 Jan 2025 18:11:47 +0000
Lines: 40
Message-ID: <mailman.83.1737137511.2912.python-list@python.org>
References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
 <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk>
 <mailman.68.1736808383.2912.python-list@python.org>
 <87plko9acw.fsf@nosuchdomain.example.com>
 <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 4QI7IbDojZjaC2WgzR8vUAsJyRs3sGHqlxAygKkzfySg==
Cancel-Lock: sha1:n8lB4eOCH2sgnTZuH/rpYNi3Bq0= sha256:HdxqQzudAe6VwVwvADOqsM6iJd0s5lofxbny09IO7dY=
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=XIF9wUNh;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.011
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(which': 0.04; 'codes':
 0.07; 'directly.': 0.07; 'world"': 0.07; '"hello': 0.09;
 'subject:GUI': 0.09; 'writes:': 0.09; 'import': 0.15; '*nix':
 0.16; 'easily.': 0.16; 'flickr': 0.16; 'from:name:alan gauld':
 0.16; 'gauld': 0.16; 'input,': 0.16; 'message-id:@yahoo.co.uk':
 0.16; 'photo-blog': 0.16; 'received:mail-wm1-x330.google.com':
 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;
 'values,': 0.16; 'whilst': 0.16; 'wrote:': 0.16; 'python': 0.16;
 "can't": 0.17; 'url:amazon': 0.19; 'to:addr:python-list': 0.20;
 'to:name:python-list@python.org': 0.24; 'library': 0.26; 'bit':
 0.27; '>>>': 0.28; 'chris': 0.28; 'etc': 0.28; 'it,': 0.29;
 'whole': 0.30; 'header:User-Agent:1': 0.30; 'packages': 0.31;
 'takes': 0.31; 'default': 0.31; 'program': 0.32; 'python-list':
 0.32; 'but': 0.32; 'received:192.168.1': 0.32; "i'm": 0.33;
 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
 'package': 0.34; 'from:addr:gmail.com': 0.34; 'lists': 0.37;
 "it's": 0.37; 'author': 0.37; 'received:192.168': 0.37; 'use':
 0.39; 'least': 0.39; 'text': 0.39; 'alan': 0.40; 'design,': 0.40;
 'difficult': 0.40; 'learn': 0.40; 'want': 0.40; 'url-
 ip:18.239/16': 0.61; 'mode': 0.62; 'showing': 0.62; 'follow':
 0.62; 'here': 0.63; 'full': 0.64; 'becomes': 0.64; 'that,': 0.68;
 'site': 0.68; 'url:author': 0.69; 'url-ip:18/8': 0.72; 'subject:.
 ': 0.73; 'quickly': 0.80; 'position': 0.81; 'blown': 0.84; 'bold':
 0.84; 'mouse': 0.84; 'subject:Tools': 0.84; 'subject:input': 0.84;
 'subject:text': 0.84; 'url-ip:184.30.158/24': 0.84; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1737137509; x=1737742309; darn=python.org;
 h=content-transfer-encoding:in-reply-to:references:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=qinbbfMgDCcpW1C7CtrC52q03Z5XufpL0FKCGTng+ag=;
 b=XIF9wUNhZ74IXvf5shxcmo1x8eejZ1M7zaa8o6tBk/vg+bcZMsOCGF2F7k/FAg6VMg
 H6YtIxPf1TlqklzeHnuvgbWrXC7WBIonRyx1zmBcJ1WR/s+7pMO0VB4Mxvv2w3XqoDRg
 9zH90QP1Ql6Z3ZkjfUlVm+WL4/uqZCAM6LSY/2rDNai3q7rt5d894OHBOAuqbZ7OwiZU
 JHZfAP1uu0ifuaUi6weoliJz86trBiNrDnA94i+TVHn2z6TOx+FAcZAhs/uIyCTs6z5u
 O8sjqPhfLsoHjT/CjxkqgmSDSg21VWVQp+5yq1BT2SvzF0QgfVqc7Y/IcUmKewmkwE/z
 j7kA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737137509; x=1737742309;
 h=content-transfer-encoding:in-reply-to:references: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=qinbbfMgDCcpW1C7CtrC52q03Z5XufpL0FKCGTng+ag=;
 b=RrhQOxu+nx7TQ6eipjXdcPPVDeM4d4+nH8lEshHj67nq2kQivgJzO9d7UTj7cDTyQS
 Vwo4JDFXTZOvvJ6xviYnG4Kvs9mWgv/DYGPjRMMX5bQR+eCn68jjkpQVkeqiEhST3ZHa
 PGjABmaXje6h80QxlF8nTw7Ar0CC2u9Gne6DopJn4JlT6MNHKRbKYPPXNOO93XhWiH+T
 F//k/nT9KhTj9yFVcG5zkbMzVljKMJ+NuySU7u2LLRjwsc43dBTLLdGEWJNH4Vdk2rhZ
 cuUMeJ7ZZREFj8xH/+yyxDGOS1pXtEZ8nMCPku/+7/ibuPKAIRkNb7uh7V/ORzRaRt3W
 t38g==
X-Gm-Message-State: AOJu0Yx1lvfLIj9x8oo6V6D40ZIe29Z7fMIT8SPp2LM6JzuT9W0jMF+l
 Sbwb9PtNkKJRtOootpkDbVKDd6HF0g4HRcH8756Vd+Wvo2SnwIl3Rfp3oA==
X-Gm-Gg: ASbGncviNmkMCvBUd1USWlPUPs8u5gdF34DH3Kpn+uUkc4nNCN5G0PNT7yeiU/w6eHB
 rqCwg27xIEDRH4XnJHjbRWfnOcvdF1YHTRkVOWwXd1avQthl42NNX7kvxMzsC4bVGj3IG4JGzt/
 Qn/dV4sPO6JaEaRPeEJ2/C7XllZ/6LWVhKvr8wHJJSmYVQq5lJtAfVFxoan4zZCgREeycCA8UxA
 JrX+04P2rEHlQ9h+DkA+6eWzVjCxzcZSTyiz03hz7bpCne1u42TOtGkjDTnmonc1hciZqjuDQ==
X-Google-Smtp-Source: AGHT+IHcqs4++eUOc0/B9Li5xhmxvwWQm5ClxX5pftcwDygp1RlQGUQ3c4gr9BTE+KVnt36tzEv7aw==
X-Received: by 2002:a05:600c:4c06:b0:434:92f8:54a8 with SMTP id
 5b1f17b1804b1-437c6a86b58mr104192465e9.0.1737137508590; 
 Fri, 17 Jan 2025 10:11:48 -0800 (PST)
X-Google-Original-From: Alan Gauld <alan.gauld@yahoo.co.uk>
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <87plko9acw.fsf@nosuchdomain.example.com>
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: <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk>
X-Mailman-Original-References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk>
 <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk>
 <mailman.68.1736808383.2912.python-list@python.org>
 <87plko9acw.fsf@nosuchdomain.example.com>
Bytes: 7727

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,
>>
>> The standard package for this is curses which comes as part
>> of the standard library on *nix distros.
> 
> The thing about curses (which may or may not be a problem) is that, by
> design, it takes over the whole screen.  If you want to do simpler text
> manipulations (showing a dismissible message, showing bold text, etc.)
> without interfering with existing text, curses can't do it, at least not
> easily.

It's not that difficult to use the terminfo codes directly. But
that won't give access to things like lists of default values, mouse
control etc that the OP wanted. But for simple text characteristics
and moving the cursor around terminfo works ok even if a bit tedious.

Here is "hello world" in bold...

import curses
curses.setupterm()
bold = curses.tigetstr('bold').decode('ascii')
normal = curses.tigetstr('sgr0').decode('ascii')

print(bold, 'Hello world', normal)

Whilst you can position the cursor etc it very quickly
becomes easier to just use full blown curses.

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