Does npyscreen support clickable grid rows?

930 Views Asked by At

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?

1

There are 1 best solutions below

0
John On

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.