[Tutor] Interactive editing of variables.

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Sat Jun 1 03:55:07 EDT 2019


Allen,

As I am using Python 3.7 under windows. I have tried to use the win32gui,
and Tkinter. Both generate the below errors and I cannot identify a module
release to support the version of Python I am using.

C:\Users\mhysn>pip install Tkinter
graphic 948 Collecting Tkinter 
 

  ERROR: Could not find a version that satisfies the requirement Tkinter
(from versions: none)                          graphic 948 ERROR: No
matching distribution
found for Tkinter


I gave up on the cursers due to the above issues and looking at example
code. It was far to complex to achieve the simple thing I wanted too do.
Easygui module has installed and I will look for examples.

The issue I have with a lot of GUI programs built for Python they generally
fail in the accessibility department for a screen reader. Most open source
software which is multi-platform supported fail in this department. I will
check out the module and see. This is a major issue for software developers
not considering all users and there is legal requirements here. Sorry, I am
falling on to my band wagon of in-accessible or non-inclusive design
products which is my passion.



-----Original Message-----
From: Tutor <tutor-bounces+mhysnm1964=gmail.com at python.org> On Behalf Of
Alan Gauld via Tutor
Sent: Saturday, 1 June 2019 4:50 PM
To: tutor at python.org
Subject: Re: [Tutor] Interactive editing of variables.

On 01/06/2019 03:53, mhysnm1964 at gmail.com wrote:

> I have no clue on how to achieve what I want to do and the code I have 
> creates an hash. As shown below:

Thats because what you want is not a standard feature of CLI apps.
You will need to do one of the following(in order of easiness):
1) Use a GUI - it then becomes a trivial matter
2) Use a pseudo GUI like curses to provide cursor control
3) Find a module that already does what you need
   (maybe readline can be made to work?)
4) Write a function yourself using screen primitives
   that manage the cursor


> for row in description:
>     text = description_rejex(row)
>     if text[0] not in narration: 
>         Result = input(text[0])
>         narration[result] = text

The standard tools allow you to input a new value and overwrite the existing
one. But there is no simple way to interactively modify an existing value
(and of course you would need to convert it to/from a string for that to be
possible)

> I have had a look and cannot find an example where I can interactively 
> edit a content of a variable at the command line. I do not want to use 
> GUI at all.

A GUI makes this a trivial problem. Simply display an edit control and
insert the current value as a string. Allow the user to modify it and when
done read the new value back. If you don't want to use a GUI you need to
provide GUI like controls yourself, either through an existing module or by
writing one. Something like easygui would be eminently suitable. But even
vanilla Tkinter is almost trivial.

The curses library will do it but that is not standard on Windows and I've
heard varying reports of how well it works there.

The readline library allows basic editing of the commands line but I'm not
sure how you would insert your variable into the command line initially...

For windows there are a couple of modules available that provide low level
cursor control and character input/output, so you could use one of those to
write such a function.

And if you search hard enough you should find that somebody, somewhere has
already done the work for you. But I don't know where...

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


_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list