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

Start page: use ipw.VBox instead of ipw.Output to display apps. #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
32 changes: 12 additions & 20 deletions home/start_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import traitlets
from aiidalab.app import AiidaLabApp
from aiidalab.config import AIIDALAB_APPS
from IPython.display import display

from home.utils import load_widget
from home.widgets import AppStatusInfoWidget
Expand Down Expand Up @@ -60,7 +59,7 @@ class AiidaLabHome:

def __init__(self):
self.config_fn = ".launcher.json"
self.output = ipw.Output()
self.output = ipw.VBox()
self._app_widgets = {}

def _create_app_widget(self, name):
Expand Down Expand Up @@ -98,17 +97,17 @@ def read_config(self):

def render(self):
"""Rendering all apps."""
self.output.clear_output()
apps = self.load_apps()

with self.output:
for name in apps:
# Create app widget if it has not been created yet.
if name not in self._app_widgets:
self._app_widgets[name] = self._create_app_widget(name)
displayed_apps = []
apps = self.load_apps()

display(self._app_widgets[name])
for name in apps:
# Create app widget if it has not been created yet.
if name not in self._app_widgets:
self._app_widgets[name] = self._create_app_widget(name)

displayed_apps.append(self._app_widgets[name])
self.output.children = displayed_apps
return self.output

def load_apps(self):
Expand Down Expand Up @@ -186,24 +185,17 @@ def __init__(self, app, allow_move=False, allow_manage=True):
class CollapsableAppWidget(ipw.Accordion):
"""Widget that represents a collapsable app as part of the home page."""

hidden = traitlets.Bool()
hidden = traitlets.Bool(None, allow_none=True)

def __init__(self, app, **kwargs):
self.app = app
app_widget = AppWidget(app, **kwargs)
super().__init__(children=[app_widget])
self.set_title(0, app.title)
# Need to observe all names here due to unidentified issue:
self.observe(
self._observe_accordion_selected_index
) # , names=['selected_index'])

@_workaround_property_lock_issue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Please remove this decorator (defined in this file) since it is not used anywhere else.

@traitlets.observe("selected_index")
def _observe_accordion_selected_index(self, change):
if (
change["name"] == "selected_index"
): # Observing all names due to unidentified issue.
self.hidden = change["new"] is None
self.hidden = change["new"] is None

@traitlets.observe("hidden")
def _observe_hidden(self, change):
Expand Down