osscar-org / widget-periodictable

A jupyter widget to select chemical elements from the periodic table.
Other
12 stars 3 forks source link

Extend the widget to also provide a list of known structures #9

Open dou-du opened 4 years ago

dou-du commented 4 years ago

This should be optional. If a list of known_structures is passed from python, in the form

known_structures = [
  [0, "BaTiO<sub>3</sub>", ["Ba", "Ti", "O"]],
  [1, "Fe", ["Fe"]],
  ...
]

(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:

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).