Why doesn't Python include non-blocking keyboard input function?

BartC bc at freeuk.com
Wed Oct 26 21:12:52 EDT 2016


On 27/10/2016 00:30, Terry Reedy wrote:
> On 10/26/2016 7:18 AM, BartC wrote:
>
>> Can tkinter do it without creating a distracting pop-up window at the
>> same time?
>
> Yes.  I already showed how on this thread.  Of course, for some text
> appications, one would be better off with a Text widget than with the
> system-specific console.
>
> Bart, you appear to have been fortunate enough to be spoiled by learning
> programming on microcomputers, where the terminal and computer are
> combined into one unit, so that the computer, and potentially the
> programmer, have access to user input actions.

Actually, I first used machines such as pdp10 and pdp11. Those mostly 
used serial terminals, a mystery to me, and they still are. It seems 
Unix is keen to propagate the mystery.

   However, Python was not
> developed on, and in not limited to use on, such machines.  Today,
> ethernet-connected *nix servers have no keyboard, mouse, or even a
> directly connected terminal.

So how does your tkinter example work in such a server? As I don't 
understand the argument that a language shouldn't have a basic keyboard 
API because some computers it could run on might not have a keyboards.

Anyway vast numbers of /consumer/ machines /do/ have displays and 
keyboards. Look at any computer in an office: it has a display and 
keyboard. Look at any laptop: display and keyboard. Even a tablet can 
have an on-screen keyboard or have a real one plugged in.

> Over 20 years ago, tk was written in tcl and C to give tcl programmers
> access to X Windows graphics terminals, including user input actions. It
> has since been ported to MS Windows and Apple OSX and adopted by other
> languages, including Python, to give the same access.

OK. I was writing graphics applications before a lot of those things 
existed. They needed to use a display and they needed user input, and I 
had to make it work. I couldn't ask my customers to wait a decade or so 
until someone invented an API before they could fully use their keyboards!

(I've looked at X Windows; bloody hell, it makes Win32/GDI look like 
child's play. It's quite frustrating see things that used to be so 
simple to do become next to impossible.)

-- 
Bartc



More information about the Python-list mailing list