Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197195

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

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.python
Subject Re: Tools to help with text mode (i.e. non-GUI) input
Date 2025-01-17 11:03 -0800
Organization None to speak of
Message-ID <87ikqd6z63.fsf@nosuchdomain.example.com> (permalink)
References (1 earlier) <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> <mailman.83.1737137511.2912.python-list@python.org>

Show all headers | View raw


Alan Gauld <learn2program@gmail.com> writes:
> 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)

Cool -- but I think you want:

print(bold, 'Hello world', normal, sep='')

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

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

RE: Tools to help with text mode (i.e. non-GUI) input Alan Gauld <learn2program@gmail.com> - 2025-01-13 22:46 +0000
  Re: Tools to help with text mode (i.e. non-GUI) input Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-01-14 16:41 -0800
    Re: Tools to help with text mode (i.e. non-GUI) input Alan Gauld <learn2program@gmail.com> - 2025-01-17 18:11 +0000
      Re: Tools to help with text mode (i.e. non-GUI) input Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-01-17 11:03 -0800
        Re: Tools to help with text mode (i.e. non-GUI) input Mats Wichmann <mats@wichmann.us> - 2025-01-17 14:11 -0700
    Re: Tools to help with text mode (i.e. non-GUI) input Grant Edwards <grant.b.edwards@gmail.com> - 2025-01-17 16:09 -0500

csiph-web