Curses/Python - How to edit predefined string

How to please insert predefined name of INPUT items ?

My efforts: (info: the character "_" is cursor)
1
2
3
4
5
6
7
def Edit_Item(stdscr, item_name)
    stdscr.addstr(1, 2, "Item Name:")
    r = stdscr.getstr(2, 16, 15)
    return r

Edit_Item(stdscr, 'Foo')
Edit_Item(stdscr, 'Bar')


Result:
1
2
Item Name: _
Item Name: _


The desired result:
1
2
Item Name: Foo_ # Foo must go edit
Item Name: Bar_ # Bar must go edit 


1
2
3
4
5
- Call function 'Edit_Item' with parameter 'Foo'           # OK
- The screen prints 'Item Name: Foo'                       # OK
- Cursor is now behind the word 'Foo_'                     # OK
- Press the key arrow left (2x) to change the cursor 'F_o' # Not work
- Edit word 'Foo' to 'Fao'


Thank you very much for your help.
Last edited on
Start by checking your return codes from stdscr.addstr() and stdscr.getstr(). That might provide a clue.
Read you wrong..
I'm saying:

1
2
3
4
5
6
7
8
9
10
11

 r = stdscr.addstr( 1, 2, "Item Name:" );

if( OK != r )
    {
    cerr << "Error: addstr() failed!" << endl;

    return;

    }


Do this anywhere you call a curses function.
No ;-)

This is exactly what I need to do in python/curses.

Demonstration in Bash

read -e -i "Foo" -p "Edit Item Name: " ITEM

Thank you..
Last edited on
Topic archived. No new replies allowed.