3

npyscreen lets you create a grid, and even set select_whole_line=True so that an entire line is selected when you move through the grid with your arrow keys. Is it possible to do something when the user picks a row in the grid and hits enter?

John
  • 2,551
  • 3
  • 30
  • 55
  • Seems like I may need to add an even handler for the enter key to my GridColTitles widget somehow. Seeing if I can figure it out... – John Jan 09 '17 at 22:58

1 Answers1

0

Turns out I can add this to my form class' create method:

self.grid_widget.add_handlers({curses.ascii.NL: self.do_stuff})

And then this to the form class:

def do_stuff(self, input):
    self.MyText.value = self.grid_widget.selected_row()
    self.MyText.display()

Note that I tried using curses.KEY_ENTER instead of curses.ascii.NL, but that didn't seem to work for some reason.

John
  • 2,551
  • 3
  • 30
  • 55