0

I am using npyscreen and i would like to understand how the switchForm method works. I did a small example that I took from the documentation and from this question (that didn't answer my question). My Code:

import npyscreen
import sys

class myEmployeeForm(npyscreen.ActionForm):
   def afterEditing(self):
      self.parentApp.setNextForm('Second')

   def create(self):
      self.myName = self.add(npyscreen.TitleText, name='Name')
      self.myDepartment = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=3, name='Department', values = ['Department 1', 'Department 2', 'Department 3'])
   self.myDate        = self.add(npyscreen.TitleDateCombo, name='Date Employed')

class secondOne(npyscreen.ActionForm):
  def afterEditing(self):
     self.parentApp.setNextForm(None)

  def create(self):
     self.myName        = self.add(npyscreen.TitleText, name='Name')
     self.myDepartment = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=3, name='Department', values = ['Department 1', 'Department 2', 'Department 3'])
     self.myDate        = self.add(npyscreen.TitleDateCombo, name='Date Employed')
     self.add_handlers({"^Q": sys.exit, "^T": self.changingForm('Second')})

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

class MyApplication(npyscreen.NPSAppManaged):
   def onStart(self):
    self.addForm('MAIN', myEmployeeForm, name='New Employee')
    self.addForm('Second', secondOne, name='New start')

if __name__ == '__main__':
  TestApp = MyApplication().run()

Can someone explain to me why I get this error :

File "/home/MyName/.local/lib/python3.5/site-packages/npyscreen/apNPSApplicationManaged.py", line 81, in switchForm
self._THISFORM.editing = False
AttributeError: 'MyApplication' object has no attribute '_THISFORM'

Thank you for your support :)

jerem0808
  • 95
  • 1
  • 12
  • For more information visit: https://stackoverflow.com/questions/68580656/npyscreen-how-do-i-edit-other-screens-forms-and-customize-it-with-widgets ``` –  Jul 29 '21 at 18:02

1 Answers1

0

My error is linked more to python than npyscreen. See here enter link description here Thank you

jerem0808
  • 95
  • 1
  • 12