def create(self): self._optionlist = npyscreen.OptionList(filename=self.FILE) self._optionlist.options.extend([ npyscreen.OptionFreeText( 'FreeText', value='', documentation='This is some documentation', ), npyscreen.OptionMultiChoice( 'MultiChoice', choices=['Choice 1', 'Choice 2', 'Choice 3'], ), npyscreen.OptionFilename('Filename'), npyscreen.OptionDate('Date'), npyscreen.OptionMultiFreeText( 'MultilineText', value='', ), npyscreen.OptionMultiFreeList('MultilineList'), ]) self.add( npyscreen.OptionListDisplay, name="Option List", values=self._optionlist.options, scroll_exit=True, max_height=None, )
def main(self): Options = npyscreen.OptionList() # just for convenience so we don't have to keep writing Options.options options = Options.options options.append(npyscreen.OptionFilename('Filename', self.default_file)) options.append( npyscreen.OptionFreeText( 'FreeText', value='', documentation="This is some documentation.")) options.append( npyscreen.OptionMultiChoice( 'Multichoice', choices=['Choice 1', 'Choice 2', 'Choice 3'])) options.append(npyscreen.OptionDate('Date', )) options.append( npyscreen.OptionMultiFreeText('Multiline Text', value='')) options.append(npyscreen.OptionMultiFreeList('Multiline List')) try: Options.reload_from_file(self.default_file) except FileNotFoundError: pass F = npyscreen.Form(name="Welcome to Npyscreen", ) ms = F.add(npyscreen.OptionListDisplay, name="Option List", values=options, scroll_exit=True, max_height=None) F.edit() Options.write_to_file(self.default_file)