Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
npyscreen 允许您创建一个网格,甚至可以设置select_whole_line=True为当您使用箭头键在网格中移动时选择整行。当用户在网格中选择一行并按回车时,是否可以做某事?
select_whole_line=True
原来我可以将它添加到我的表单类的创建方法中:
self.grid_widget.add_handlers({curses.ascii.NL: self.do_stuff})
然后这是表单类:
def do_stuff(self, input): self.MyText.value = self.grid_widget.selected_row() self.MyText.display()
请注意,我尝试使用 curses.KEY_ENTER 而不是 curses.ascii.NL,但由于某种原因这似乎不起作用。