(i.e. a list of lists of length three, being an ID (can be a string, an integer, ... - no checks should be done); a string to be rendered in HTML; and a list of elements in the structure), then:
show a list of elements near the periodic table (possibly with a text-search like on Materials Cloud/discover/2d?), in the order specified
disable all chemical elements not present in any of the structures
bind the content of the list to show only the elements that have at least one element selected (or show all if none is selected?)
when a structure is selected, update a new attribute selected_structure (but give a way to unselect it) with the ID of the selected structure.
Note: IDs are not required to be unique (but then, there return value will not make it possible to distinguish what has been clicked... but for some cases this might be ok, e.g. if the ID is used to generate a URL, and two entries point to the same URL).
For the latter point, an option could be to provide instead a link to jump when clicking, but for a widget typically it is better to provide the data back without jumping to a different page (if needed, this can be done from python, observing events on the selected_structure variable and redirecting if a valid structure has been selected).
This should be optional. If a list of
known_structures
is passed from python, in the form(i.e. a list of lists of length three, being an ID (can be a string, an integer, ... - no checks should be done); a string to be rendered in HTML; and a list of elements in the structure), then:
selected_structure
(but give a way to unselect it) with the ID of the selected structure.Note: IDs are not required to be unique (but then, there return value will not make it possible to distinguish what has been clicked... but for some cases this might be ok, e.g. if the ID is used to generate a URL, and two entries point to the same URL).
For the latter point, an option could be to provide instead a link to jump when clicking, but for a widget typically it is better to provide the data back without jumping to a different page (if needed, this can be done from python, observing events on the
selected_structure
variable and redirecting if a valid structure has been selected).