From b959f9f6b292974ee554d4b8eed74c955723d767 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Thu, 28 Nov 2024 15:46:01 +0000 Subject: [PATCH 1/2] modifications to the EditStructureData Widgets --- src/aiidalab_qe/common/widgets.py | 36 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/aiidalab_qe/common/widgets.py b/src/aiidalab_qe/common/widgets.py index b42301083..d7061ad63 100644 --- a/src/aiidalab_qe/common/widgets.py +++ b/src/aiidalab_qe/common/widgets.py @@ -440,7 +440,11 @@ def __init__(self, title="", **kwargs): self._status_message = StatusHTML() self.atom_selection = ipw.Text( - description="Index of atoms", value="", layout={"width": "initial"} + placeholder="e.g. 1..5 8 10", + description="Index of atoms", + value="", + style={"description_width": "100px"}, + layout={"width": "initial"}, ) self.from_selection = ipw.Button(description="From selection") self.from_selection.on_click(self._from_selection) @@ -478,6 +482,10 @@ def __init__(self, title="", **kwargs): button_style="primary", layout={"width": "100px"}, ) + self.scroll_note = ipw.HTML( + value="

Note: The table is scrollable.

", + layout={"visibility": "hidden"}, + ) self.tag_display = ipw.Output() self.add_tags.on_click(self._add_tags) self.reset_tags.on_click(self._reset_tags) @@ -491,7 +499,18 @@ def __init__(self, title="", **kwargs): super().__init__( children=[ ipw.HTML( - "Adding a tag to atoms", + "Set custom tags for atoms", + ), + ipw.HTML( + """ +

+ These are used to distinguish atoms of the same chemical element.
+ For example, they can be used to assign different initial magnetization values for antiferromagnetic systems. +

+

+ Note: Atom indices are 1-based (first atom has index 1, second atom has index 2, ...). +

+ """ ), ipw.HBox( [ @@ -501,10 +520,11 @@ def __init__(self, title="", **kwargs): ] ), self.tag_display, + self.scroll_note, ipw.HBox([self.add_tags, self.reset_tags, self.reset_all_tags]), self._status_message, ipw.HTML( - "Define periodicity", + '
Set structure periodicity
' ), ipw.HTML("""

Select the periodicity of your system.

@@ -530,14 +550,18 @@ def _display_table(self, _=None): current_tags = self.structure.get_tags() chemichal_symbols = self.structure.get_chemical_symbols() - if selection and (max(selection) <= (len(self.structure) - 1)): + if ( + selection + and (min(selection) >= 0) + and (max(selection) <= (len(self.structure) - 1)) + ): table_data = [] for index in selection: tag = current_tags[index] symbol = chemichal_symbols[index] if tag == 0: tag = "" - table_data.append([f"{index}", f"{symbol}", f"{tag}"]) + table_data.append([f"{index+ 1}", f"{symbol}", f"{tag}"]) # Create an HTML table table_html = "" @@ -558,10 +582,12 @@ def _display_table(self, _=None): with self.tag_display: clear_output() display(HTML(table_html)) + self.scroll_note.layout = {"visibility": "visible"} else: self.tag_display.layout = {} with self.tag_display: clear_output() + self.scroll_note.layout = {"visibility": "hidden"} def _from_selection(self, _=None): """Set the atom selection from the current selection.""" From 06b3e84af05f29cef5bc3f6b1a28b90053f69f1b Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Thu, 28 Nov 2024 16:18:04 +0000 Subject: [PATCH 2/2] adapting the NOTE to the same style as in the periodicity widget --- src/aiidalab_qe/common/widgets.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aiidalab_qe/common/widgets.py b/src/aiidalab_qe/common/widgets.py index d7061ad63..51e2536eb 100644 --- a/src/aiidalab_qe/common/widgets.py +++ b/src/aiidalab_qe/common/widgets.py @@ -507,8 +507,12 @@ def __init__(self, title="", **kwargs): These are used to distinguish atoms of the same chemical element.
For example, they can be used to assign different initial magnetization values for antiferromagnetic systems.

-

- Note: Atom indices are 1-based (first atom has index 1, second atom has index 2, ...). +

NOTE:

+ + + Note:

""" ),