summaryrefslogtreecommitdiff
path: root/docs/tutorial/edit.py
blob: 36bcd9ea2c764fd7f14eb55e9be04f63c8f2471c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import urwid

def do_reply(input):
    if input != 'enter':
        return
    if fill.body == ask:
        fill.body = urwid.Text(u"Nice to meet you,\n"+
            ask.edit_text+".")
        return True
    else:
        raise urwid.ExitMainLoop()

ask = urwid.Edit(u"What is your name?\n")
fill = urwid.Filler( ask )
loop = urwid.MainLoop(fill, unhandled_input=do_reply)
loop.run()