I want to use curses.KEY_UP and curses.KEY_DOWN to increment and decrement the index using the functions I created. My handlers can use any key but it doesn't seem to be working when using the up and down key.
import npyscreen, curses
index = 0
class MyTestApp(npyscreen.NPSAppManaged):
def onStart(self):
self.registerForm("MAIN", MainForm())
class MainForm(npyscreen.Form):
def create(self):
for i in range(10):
self.add(npyscreen.FixedText, value='message:'+str(i))
self.add_handlers({"^R": self.spawn_notify_popup,
curses.KEY_UP: self.minus_one,
curses.KEY_DOWN: self.add_one})
def add_one(self, key):
global index
if(index < 30):
index+=1
def minus_one(self, key):
global index
if(index > 0):
index-=1
def spawn_notify_popup(self, code_of_key_pressed):
message_to_display = 'I popped up passed: {}'.format(index)
npyscreen.notify_confirm(message_to_display, title= 'title')
def afterEditing(self):
self.parentApp.setNextForm(None)
if __name__ == '__main__':
TA = MyTestApp()
TA.run()