npyscreen icon indicating copy to clipboard operation
npyscreen copied to clipboard

while_waiting() does not seem to work within NPSAppManaged apps.

Open mecworks opened this issue 7 years ago • 1 comments

I can get while_waiting to work on NPSApp instances but not in forms added to a NPSAppManaged instance.

i.e. If you add a while_waiting() method to the MainForm class in EXAMPLE-ManagedApp.py example, it will never get called.

mecworks avatar Apr 27 '17 23:04 mecworks

I know it's been a few years but I'm struggling with that problem at the moment. Any insight?

class Action(npyscreen.ActionForm):
    def while_waiting(self):
        print('test')
        curses.beep()

    def create(self):    
        self.date_widget = self.add(npyscreen.FixedText, value=datetime.now(), editable=False)
        y, x = self.useable_space()
        self.add(npyscreen.TitleSelectOne, name = "Type de l'appareil:", scroll_exit=True, max_height=5,values= APPAREILS )
        obj = self.add(npyscreen.TitlePager, name="log",
              custom_highlighting=False, scroll_exit=True, editable=False, values=log,
              rely=y // 4, max_width=x // 2 - 5, max_height=y // 2)

    def writePass(self):
        self.parentApp.draginoSerial.writePass()
    def afterEditing(self):
        self.parentApp.setNextForm(None)

class monAppli(npyscreen.NPSAppManaged):

    def onStart(self):
        self.draginoSerial = draginoSerial()
        self.keypress_timeout_default = 10
        self.registerForm("MAIN", ChoixSerial())
        self.registerForm("CONF", Action())
    


if __name__ == '__main__':
    try:
        serialPorts = serial_ports()
        TA = monAppli().run()
    except KeyboardInterrupt:
        print('Interrupted')
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)

jpeg2600 avatar Jul 09 '21 16:07 jpeg2600