Skip to content

Commit

Permalink
Add link button to examples notebook (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass authored Feb 14, 2025
1 parent 9b9e37a commit 09df961
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/aiidalab_qe/app/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,34 @@ def __init__(self) -> None:
disabled=True,
)

self.new_workchain_link = LinkButton(
description="New calculation",
link="./qe.ipynb",
icon="plus-circle",
disabled=True,
)

self.setup_resources_link = LinkButton(
description="Setup resources",
link="../home/code_setup.ipynb",
icon="database",
disabled=True,
)

self.download_examples_link = LinkButton(
description="Download examples",
link="./examples.ipynb",
icon="download",
disabled=True,
)

self.new_workchain_link = LinkButton(
description="New calculation",
link="./qe.ipynb",
icon="plus-circle",
disabled=True,
)

self.controls = ipw.HBox(
children=[
self.guide_toggle,
self.about_toggle,
self.calculation_history_link,
self.setup_resources_link,
self.download_examples_link,
self.new_workchain_link,
],
)
Expand Down
10 changes: 6 additions & 4 deletions src/aiidalab_qe/common/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,18 +1409,18 @@ def render(self):
layout=ipw.Layout(width="auto"),
)

import_button = ipw.Button(
self.import_button = ipw.Button(
description="Import",
button_style="success",
layout=ipw.Layout(width="fit-content"),
icon="download",
)
ipw.dlink(
(self.selector, "value"),
(import_button, "disabled"),
(self.import_button, "disabled"),
lambda value: not value,
)
import_button.on_click(self.import_archives)
self.import_button.on_click(self.import_archives)

self.info = ipw.HTML()

Expand All @@ -1446,7 +1446,7 @@ def render(self):
self.selector,
ipw.HBox(
[
import_button,
self.import_button,
self.info,
history_link,
],
Expand All @@ -1472,10 +1472,12 @@ def get_options(self) -> list[tuple[str, str]]:
return []

def import_archives(self, _):
self.import_button.disabled = True
if self.logger and self.clear_log_on_import:
self.logger.value = ""
for filename in self.selector.value:
self.import_archive(filename)
self.import_button.disabled = False

def import_archive(self, filename: str):
self.info.value = self.INFO_TEMPLATE.format(f"Importing {filename}")
Expand Down

0 comments on commit 09df961

Please sign in to comment.