I would like to update values list of TitleSelectOne widget based on selected value from another TitleSelectOne widget. I've tried to use value_changed_callback option but no luck so far.
I don't know if the list is not updated or maybe the form is not refreshed with new values.
Could anyone tell me what I'm missing, the code I've got at the moment below.
import npyscreen
def update_product_options(widget):
widget.parent.parentApp.getForm('MAIN').product_options = ['NPSA','NPSHH']
widget.parent.parentApp.getForm('MAIN').display()
class UnipatchMainForm(npyscreen.Form):
def afterEditing(self):
self.parentApp.setNextForm(None)
def create(self):
#Add widgets to collect info
self.product_options = ['...']
self.product_name = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=5, name='Product:', values = ['Sonet', 'Durabill', 'Gina','Clava'],value_changed_callback=update_product_options)
self.product_value = self.add(npyscreen.TitleSelectOne, max_height=5,scroll_exit=True,name='Product Value:', values=self.product_options)
class UnipatchApp(npyscreen.NPSAppManaged):
def onStart(self):
self.addForm('MAIN', UnipatchMainForm, name='Unipatch')
if __name__ == '__main__':
UnipatchApp = UnipatchApp().run()