Does one have to use curses to read single characters from keyboard?

Antoon Pardon antoon.pardon at vub.be
Sun Dec 11 13:00:36 EST 2022



Op 11/12/2022 om 12:32 schreef Stefan Ram:
> ram at zedat.fu-berlin.de (Stefan Ram) writes:
>> Curses is not portable IIRC. A more portable means would
>> be to use tkinter with the "bind" function to bind keys.
> import tkinter
>
> text = tkinter.Text()
> text.pack()
> text.bind\
> ( "<y>",
>    lambda event:
>    text.insert
>    ( tkinter.END, "Y\nFormatting drive C:\n...\n" )or "break" )
> text.insert( tkinter.END, "Format drive C:?\n" )
> text.focus()
>
> tkinter.mainloop()
>
>    Not allowing users to edit their keypresses before confirming
>    them with [Return]. What could possibly go wrong?

Nothing that can't go wrong otherwise. It is my experience that
when a [Return] is needed, people just type in a two key combination.
They don't type one key, then check, then type [Return].

So in practice the same things go wrong, either way.

-- 
Antoon Pardon.


More information about the Python-list mailing list