BlissDialog again with UserChoice
If you launch again a BlissDialog with an UserChoice without redefine the UserChoice, it can crash.
Example:
from bliss.shell.cli.user_dialog import UserInput, UserCheckBox, UserChoice
from bliss.shell.cli.pt_widgets import BlissDialog
dlg1 = UserInput(label="User name")
dlg2 = UserCheckBox(label="Enable auto-save", defval=True)
dlg3 = UserChoice(label="File format", values=[('txt','.txt'), ('hdf5','.hdf5'), ('tiff','.tiff')])
BlissDialog( [ [dlg1], [dlg2, dlg3] ] , title='Bliss manager',paddings=(3,3)).show()
#
#---> choose Cancel
#
BlissDialog( [ [dlg1], [dlg2, dlg3] ] , title='Bliss manager',paddings=(3,3)).show()
#
#---> choose OK
#
BlissDialog( [ [dlg1], [dlg2, dlg3] ] , title='Bliss manager',paddings=(3,3)).show()
#
#---> Crash
#
It's due to the default value detection/assignement in pt_widgets.py (667)
I propose to add this :
if isinstance(self.dlg.defval, str):
self.dlg.defval=[i[0] for i in self.dlg.values].index(self.dlg.defval)
before this :
if self.dlg.defval >= 0 and self.dlg.defval < len(self.dlg.values):
self.wdata.current_value = self.dlg.values[self.dlg.defval][0]
self.wdata._selected_index = self.dlg.defval
Edited by Benoit Formet