A "renderer" parameter for transforming the underlying value into a nicer display value
Etherian opened this issue · comments
On elements where it makes sense, add a parameter that takes a callback which transforms the widget's underlying values into displayed ones that are nicer-looking and easier for the user to understand.
For example, I have a ComboBox of dictionaries like
from magicgui import ComboBox
ComboBox(
value={'color': 'red', 'shape': 'square'},
choices=[
{'color': 'red', 'shape': 'square'},
{'color': 'yellow', 'shape': 'circle'}
],
)
It would be nice if I could display something nicer for the user with
ComboBox(
value={'color': 'red', 'shape': 'square'},
choices=[
{'color': 'red', 'shape': 'square'},
{'color': 'yellow', 'shape': 'circle'}
],
renderer=lambda val: f'val["color"] val["shape"]'
)
yeah, I like that a lot! feel free to make a PR, or I will try to get around to it in the next few weeks.