0
私はnpyscreenを使用しています。私はswitchFormメソッドの仕組みを理解したいと思います。 私はドキュメントから取った小さなサンプルを行いました。this question(これは私の質問に答えなかった)からです。 マイコード:私はこのエラーを取得する理由npyscreen - switchForm(formid)エラー
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()
誰かが私に説明することができます:
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'
をご支援いただきありがとうございます:)