Skip to content

Commit

Permalink
include layout
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresOrtegaGuerrero committed Oct 4, 2024
1 parent b1dd91a commit 23b01a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
16 changes: 1 addition & 15 deletions src/aiidalab_qe/plugins/electronic_structure/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,5 @@ def _update_view(self):

_bands_dos_widget = BandPdosWidget(bands=bands_node, pdos=pdos_node)

plot_container = ipw.HTML(
"""
<div style='overflow-x: auto; width: 80%; max-width: 80%;'>
<!-- Placeholder for the Plotly plot widget -->
</div>
"""
)
_bands_dos_widget.layout = ipw.Layout(width="1000px")
self.children = [
ipw.VBox(
[
plot_container, # The scrollable container
_bands_dos_widget, # The actual Plotly widget
]
)
]
self.children = [_bands_dos_widget]
5 changes: 4 additions & 1 deletion src/aiidalab_qe/plugins/pdos/result.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""PDOS results view widgets"""

import ipywidgets as ipw

from aiidalab_qe.common.bandpdoswidget import BandPdosWidget
from aiidalab_qe.common.panel import ResultPanel

Expand All @@ -21,5 +23,6 @@ def _update_view(self):

_pdos_plot_view = BandPdosWidget(pdos=pdos_node)

# update the electronic structure tab
_pdos_plot_view.layout = ipw.Layout(width="1000px")

self.children = [_pdos_plot_view]
25 changes: 11 additions & 14 deletions tests/test_plugins_electronic_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,28 @@ def test_electronic_structure(generate_qeapp_workchain):
result = Result(node=wkchain.node)
result._update_view()

assert isinstance(result.children[0].children[1], BandPdosWidget)
assert isinstance(result.children[0].children[1].bandsplot_widget, go.FigureWidget)
assert isinstance(result.children[0], BandPdosWidget)
assert isinstance(result.children[0].bandsplot_widget, go.FigureWidget)

# Check if data is correct
assert result.children[0].children[1].bands_data is not None
assert result.children[0].children[1].bands_data["pathlabels"] is not None
assert result.children[0].children[1].pdos_data is not None
assert result.children[0].bands_data is not None
assert result.children[0].bands_data["pathlabels"] is not None
assert result.children[0].pdos_data is not None

# Check Bands axis
assert result.children[0].bandsplot_widget.layout.xaxis.title.text == "k-points"
assert (
result.children[0].children[1].bandsplot_widget.layout.xaxis.title.text
== "k-points"
)
assert (
result.children[0].children[1].bandsplot_widget.layout.xaxis2.title.text
result.children[0].bandsplot_widget.layout.xaxis2.title.text
== "Density of states"
)
assert (
result.children[0].children[1].bandsplot_widget.layout.yaxis.title.text
result.children[0].bandsplot_widget.layout.yaxis.title.text
== "Electronic Bands (eV)"
)
assert isinstance(
result.children[0].children[1].bandsplot_widget.layout.xaxis.rangeslider,
result.children[0].bandsplot_widget.layout.xaxis.rangeslider,
go.layout.xaxis.Rangeslider,
)
assert result.children[0].children[1].bands_data["pathlabels"][0] == list(
result.children[0].children[1].bandsplot_widget.layout.xaxis.ticktext
assert result.children[0].bands_data["pathlabels"][0] == list(
result.children[0].bandsplot_widget.layout.xaxis.ticktext
)

0 comments on commit 23b01a0

Please sign in to comment.