npyscreen - switchForm(formid)错误

时间:2017-08-08 13:46:32

标签: python-3.x python-curses npyscreen

我正在使用npyscreen,我想了解switchForm方法的工作原理。 我做了一个小例子,我从文档和this question(我没有回答我的问题)中提取。 我的代码:

Sub

有人可以向我解释为什么我会收到此错误:

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()

感谢您的支持:)

1 个答案:

答案 0 :(得分:0)

我的错误与python的关联比npyscreen更多。 见enter link description here 谢谢