Skip to content

Commit

Permalink
WID-223: improve connectivity widget layout
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbacter01 committed Aug 28, 2023
1 parent bd73016 commit 851444d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
20 changes: 10 additions & 10 deletions notebooks/Connectivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
"name": "stdout",
"output_type": "stream",
"text": [
"25-08-2023 02:41:22 - DEBUG - tvbwidgets - Package is not fully installed\n",
"25-08-2023 02:41:22 - DEBUG - tvbwidgets - Version read from the internal package.json file\n",
"25-08-2023 02:41:22 - INFO - tvbwidgets - Version: 1.5.0\n",
"2023-08-25 14:41:28,344 - INFO - tvb.storage.h5.encryption.data_encryption_handler - Cannot import syncrypto library.\n",
"25-08-2023 02:41:28 - INFO - tvbwidgets.core.pse.parameters - ImportError: Dask dependency is not included, so this functionality won't be available\n",
"2023-08-25 14:41:28,543 - WARNING - tvb.basic.readers - File 'hemispheres' not found in ZIP.\n"
"28-08-2023 12:46:20 - DEBUG - tvbwidgets - Package is not fully installed\n",
"28-08-2023 12:46:20 - DEBUG - tvbwidgets - Version read from the internal package.json file\n",
"28-08-2023 12:46:20 - INFO - tvbwidgets - Version: 1.5.0\n",
"2023-08-28 12:46:26,629 - INFO - tvb.storage.h5.encryption.data_encryption_handler - Cannot import syncrypto library.\n",
"28-08-2023 12:46:26 - INFO - tvbwidgets.core.pse.parameters - ImportError: Dask dependency is not included, so this functionality won't be available\n"
]
}
],
"source": [
"from tvbwidgets.api import ConnectivityWidgetReact\n",
"from tvb.datatypes.connectivity import Connectivity\n",
"\n",
"connectivity = Connectivity.from_file() # defaults to connectivy_76.zip\n",
"# connectivity = Connectivity.from_file() # defaults to connectivy_76.zip\n",
"\n",
"\n",
"# wid = ConnectivityWidgetReact(connectivity=connectivity)\n",
"# wid"
Expand All @@ -46,18 +46,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2023-08-25 14:41:28,570 - WARNING - tvb.basic.readers - File 'hemispheres' not found in ZIP.\n"
"2023-08-28 12:46:26,831 - WARNING - tvb.basic.readers - File 'hemispheres' not found in ZIP.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b1d4cf7c16d244c1aae087b72e8c3218",
"model_id": "b8aad67a154242199518557006d0e75d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ConnectivityWidget(children=(Connectivity2DViewer(children=(Dropdown(description='Matrix:', index=1, options=("
"ConnectivityWidget(children=(HTML(value='<h1>Connectivity - 76</h1>'), Tab(children=(ConnectivityViewers(child"
]
},
"metadata": {},
Expand Down
40 changes: 37 additions & 3 deletions tvbwidgets/ui/connectivity_ipy/connectivity_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,43 @@ def on_change(change):
self.children = (dropdown, *self.children)


class ConnectivityWidget(ipywidgets.Tab):
class ConnectivityOperations(ipywidgets.VBox):
def __init__(self, connectivity, **kwargs):
super().__init__(**kwargs)
children = [Connectivity2DViewer(connectivity)]
self.set_title(0, 'Connectivity 2D Viewer')
children = [
ipywidgets.HTML(value=f'Placeholder text for operations on Connectivity-{connectivity.number_of_regions}')]
self.children = children


class ConnectivityViewers(ipywidgets.VBox):
def __init__(self, connectivity, **kwargs):
super().__init__(**kwargs)
self.children = (
Connectivity2DViewer(connectivity),
)


class ConnectivityWidget(ipywidgets.VBox, TVBWidget):
def add_datatype(self, datatype):
"""
Doesn't allow this opp at this time
"""
pass

def __init__(self, connectivity, **kwargs):
super().__init__(**kwargs)

config = ConnectivityConfig(name=f'Connectivity - {str(connectivity.number_of_regions)}')

tabs = (
ConnectivityViewers(connectivity),
ConnectivityOperations(connectivity)
)
tabs_container = ipywidgets.Tab(children=tabs)
tabs_container.set_title(0, 'Viewers')
tabs_container.set_title(1, 'Operations')
children = [
ipywidgets.HTML(value=f'<h1>{config.name}</h1>'),
tabs_container
]
self.children = children

0 comments on commit 851444d

Please sign in to comment.