Hi,
I made a fast check in stack overflow and found someone with your issue.
https://stackoverflow.com/questions/5403138/how-to-set-a-default-string-for-raw-input
import readline
def rlinput(prompt, prefill=''):
readline.set_startup_hook(lambda: readline.insert_text(prefill))
try:
return input(prompt)
finally:
readline.set_startup_hook()
default_value = "an insecticide"
stuff = rlinput("Caffeine is: ", default_value)
print("final answer: " + stuff)
More info on what's going on here:
https://stackoverflow.com/a/2533142/445131
On 1.6.2019 г. 11:48, mhysnm1964@xxxxxxxxx wrote:
It isn’t an exercise. I have a list of values that I want to modify by hand. I can write them to a file. But I want to have it interactive. Easygui which is an easy GUI module is not accessible. I was hoping for Win32. But I cannot install it using my version of python. Looks Like I might try and different distribution and hope it includes win32.
*From:*program-l-bounce@xxxxxxxxxxxxx <program-l-bounce@xxxxxxxxxxxxx> *On Behalf Of *Dzhovani
*Sent:* Saturday, 1 June 2019 6:38 PM
*To:* program-l@xxxxxxxxxxxxx
*Subject:* [program-l] Re: Command line interface editing using python.
Hi,
You can emulate key presses to fill in the text to be edited on the console. After the program is done typing it, you can apply your edits and send them with enter. However, unless it is some kind of exercise, most likely you can just use a command line editor like vim.
On 1.6.2019 г. 10:58, mhysnm1964@xxxxxxxxx <mailto:mhysnm1964@xxxxxxxxx> wrote:
Nick,
I am going down the path of GuI. I only need a simple box popping
up with the value already populated. Cursors I cannot install
under windows and I have just found out it is not reliable. I am
having issues with installing win32gui module. Saying the version
is not supported. Someone has recommended another module which I
will check out.
I really need to look at the book which was posted a couple of
days ago for GUI programming. But I don’t have bookshare access at
this point of time. I might need to check other sources.
*From:*program-l-bounce@xxxxxxxxxxxxx
<mailto:program-l-bounce@xxxxxxxxxxxxx>
<program-l-bounce@xxxxxxxxxxxxx>
<mailto:program-l-bounce@xxxxxxxxxxxxx> *On Behalf Of
*ntsiklauri2@xxxxxxxxx <mailto:ntsiklauri2@xxxxxxxxx>
*Sent:* Saturday, 1 June 2019 4:45 PM
*To:* program-l@xxxxxxxxxxxxx <mailto:program-l@xxxxxxxxxxxxx>
*Subject:* [program-l] Re: Command line interface editing using
python.
If you want to show text of test after the value of modify you can
concatenate it. that would work as long as it is a string. if you
are dealing with numbers, you can pass it to str function and
concatenate it that way. see the code below.
x=input(“modify: ”+a)
for detecting keypresses in console, i don't exactly remember the
function that lets you do that right now. i'll have to look
through my projects and get back to you.
Hth.
Nick.
Sent from my iPhone
On Jun 1, 2019, at 07:22, <mhysnm1964@xxxxxxxxx
<mailto:mhysnm1964@xxxxxxxxx>> <mhysnm1964@xxxxxxxxx
<mailto:mhysnm1964@xxxxxxxxx>> wrote:
All,
I have a list (array) with pre-populated. I want to modify
some of the elements via console using python. I have found
the input() command for python 3.7. But function does not
allow me to insert a variable to be edited.
For example:
A = ‘test of text’
B = Input (‘Modify:’)
The above function does not allow you to show the following
and modify:
Modify: test of text
Then I want to use the backspace, arrow keys, etc to change
the “test of text” to something else and on pressing enter the
new value is saved in a variable. This I want to do in the
console. Not GUI.