dialog: Added UserChoice2 + few fixes
This PR mostly added UserChoice2
in order to provide a dialog a bit more consistent.
UserChoice.defval
was based on index, which the result was a value. As result it was difficult to use.
Here is part of the test to show the difference
ch_values = [(roby, roby.name), (robz, robz.name)]
[...]
UserChoice(
name="mychoice",
values=ch_values,
defval=1, # <---- guess what is selected here
label="Select a motor",
),
UserChoice2(
name="mychoice2",
values=ch_values,
defval=robz, # <---- here the selection is obvious
label="Select a motor",
),
[...]
assert result["mychoice"] is robz
assert result["mychoice2"] is robz # <---- and the result is consistent with the default value
UserChoice
is still on the base code to not break existing code. We could deprecate it later.