def keypress(self, size, key):
key = super(ConversationListBox, self).keypress(size, key)
if key != 'enter':
return key
name = self.focus[0].edit_text
if not name:
raise urwid.ExitMainLoop()
# replace or add response
self.focus.contents[1:] = [(answer(name), self.focus.options())]
pos = self.focus_position
# add a new question
self.body.insert(pos + 1, question())
self.focus_position = pos + 1
评论列表
文章目录