0

I'm experiencing some issues with the use of the NPSAppManaged.switchForm(formid) method. I am attempting to create a welcome screen (refer to 'systemWelcomeScreenForm') which uses key handlers to switch the current form to another.

In the example code below (refer to playground.py), I am simply wanting to test this concept by making a user input of 'CTRL'+'T' switch the current form to the 'createPlaceholderForm'. However, I am receiving the error shown in error one.

playground.py

#!/usr/bin/env python
# encoding: utf-8

# File Name:    playground.py
# Author:       Jack Winch
# Sys. Version: ALPHA

# Comments:
# =========
# This file has been created so as to experiment with the implementation of a DBMS front-end, using npyscreen.

from npyscreen import *
import sys

# WELCOME SCREEN FORM
# ===================

class systemWelcomeScreenForm(FormBaseNew):

        def create(self):

                self.add_handlers({"^Q": sys.exit, "^T": self.change_form("createPlaceholderForm")})

                self.add(TitleFixedText, name = "openCalDBMS Primary Options Menu", editable=False, relx=4, rely=2, labelColor='STANDOUT')
                self.add(TitleFixedText, name = "================================", editable=False, relx=4, rely=3, labelColor="STANDOUT")

                self.add(TitleFixedText, name = "Function Keys:    CNTRL+Q - Exit System", editable=False, relx=4, rely=44)

                self.add(TitleText, name = "Option ===>", relx=4, rely=40, labelColor="STANDOUT", begin_entry_at=13, use_two_lines=False)

        def change_form(self, name):
                self.parentApp.switchForm(name)


# CREATE PLACEHOLDER FORM
# =======================
class createPlaceholderForm(ActionForm):

        def create(self):

                self.add(TitleFixedText, name="Test", editable=False, labelColor='STANDOUT', relx=4, rely=2)

        def on_ok(self):
                self.parentApp.setNextForm("MAIN")

        def on_cancel(self):
                self.parentApp.setNextForm("MAIN")


class ApplicationHandler(NPSAppManaged):

        def onStart(self):
                self.addForm('MAIN', systemWelcomeScreenForm, name="openCalDBMS | Welcome Screen", min_columns=120, min_lines=48)
                self.addForm('createPlaceholderForm', createPlaceholderForm, name='openCalDBMS | Create Instrumentation Placeholder for Ordered Instruments'$

if __name__ == '__main__':
        Application = ApplicationHandler().run()

error one: Error experienced when trying to execute the code example above.

My apologies about the error format - I've been having trouble formatting the text.

I've referred to the npyscreen documentation, scoured this site and searched the internet but unfortunately I have not found anything on this error or usage of the NPSAppManaged.switchForm(formid), other than the npyscreen documentation.

Your help would be greatfully appreciated and apologies about the formatting of the generated error,

JrDeveloper

JackWinch
  • 11
  • 3

1 Answers1

0

Found the issue.

    def change_form(self, name):

should be

    def change_form(self, name, *args, **keywords):
JackWinch
  • 11
  • 3