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 5 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,18 @@ def _render(self):
""")
self.atom_coordinates_table = TableWidget()
self._generate_table(structure.get_ase())

# Get information from the structure
structure_info = self._get_structure_info(structure)
AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved

# Add the children to the container
AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved
self.results_container.children = [
structure_info,
self.widget,
self.table_description,
self.atom_coordinates_table,
]

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 +50,19 @@ def _render(self):
ngl._set_size("100%", "300px")
ngl.control.zoom(0.0)

def _get_structure_info(self, structure):
return 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>
"""
)

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