Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info relaxed structure results tab #1066

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ipywidgets as ipw

from aiidalab_qe.common.panel import ResultsPanel
from aiidalab_qe.common.time import format_time, relative_time
from aiidalab_qe.common.widgets import TableWidget
from aiidalab_widgets_base.viewers import StructureDataViewer

Expand All @@ -26,11 +27,22 @@ def _render(self):
""")
self.atom_coordinates_table = TableWidget()
self._generate_table(structure.get_ase())
self.results_container.children = [

# Basic widgets
children = [
self.widget,
self.table_description,
self.atom_coordinates_table,
]

# Add structure info if it is a relaxed structure
if "relax" in self._model.properties:
self._initialize_structure_info(structure)
children.insert(0, self.structure_info)

# Add the children to the container
self.results_container.children = tuple(children)

AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved
self.atom_coordinates_table.observe(self._change_selection, "selected_rows")
# Listen for changes in self.widget.displayed_selection and update the table
self.widget.observe(self._update_table_selection, "displayed_selection")
AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -42,6 +54,19 @@ def _render(self):
ngl._set_size("100%", "300px")
ngl.control.zoom(0.0)

def _initialize_structure_info(self, structure):
self.structure_info = ipw.HTML(
f"""
<div style='line-height: 1.4;'>
<strong>PK:</strong> {structure.pk}<br>
<strong>Label:</strong> {structure.label}<br>
<strong>Description:</strong> {structure.description}<br>
<strong>Number of atoms:</strong> {len(structure.sites)}<br>
<strong>Creation time:</strong> {format_time(structure.ctime)} ({relative_time(structure.ctime)})<br>
</div>
"""
)
AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved

def _generate_table(self, structure):
data = [
[
Expand Down
Loading