Provide custom non-unique labels to Select widget

Hello,

I have a dictionary which looks like this:

{'d6abe71c-71b1-11ec-9c05-d8c497859e03': 'Biology',
 'd6b00ee8-71b1-11ec-88a1-d8c497859e03': 'Chemistry',
 'd6b00ee9-71b1-11ec-a182-d8c497859e03': 'Physics',  
 'd6b00eea-71b1-11ec-a930-d8c497859e03': 'Biology',
 'd6b00eeb-71b1-11ec-aed6-d8c497859e03': 'Chemistry',
 'd6b00eec-71b1-11ec-ac9e-d8c497859e03': 'Physics'}`

I would like to display it as a Select widget, using the dictionary values as labels (since the keys aren’t particularly human-readable) but returning the UUIDs (keys) as the widgets value (for further querying my data model by UUID).

From what I understood from the documentation, the Select widget only takes labels in the form of a {label:value} dictionary in the options, which makes it impossible to use the same label multiple times (as the dictionary keys have to be unique).

Is there any other way to provide non-unique custom labels?

Hi @dabbatelli !
Yes I don’t think it’s actually possible. But how did you intend the user to choose between two items identically named (like Biology)?

Hello, and thanks for the answer.

In my real application, the labels would be a synthetic & human readable (but potentially non-unique) representation of a larger object (referenced by UUID), to be fetched from an API at runtime & displayed in its entirety in an adjacent panel upon selection.

From the user point of view, knowing that “the item I’m clicking is about Biology, there might be more like it in the list” is still better than “I’m clicking on an item with a very long UUID I don’t know anything about”.

I have now opened a feature request for this: https://github.com/holoviz/panel/issues/3102