Skip to content

Commit

Permalink
Vuetify is now working beautifully. Pun intended.
Browse files Browse the repository at this point in the history
  • Loading branch information
SaOgaz committed May 22, 2019
1 parent d2dc0f7 commit 91695f4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 71 deletions.
49 changes: 15 additions & 34 deletions examples/cubeviz-example.ipynb
Expand Up @@ -20,7 +20,9 @@
],
"source": [
"from IPython.core.display import display, HTML\n",
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n"
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
"\n",
"import ipyvuetify as v"
]
},
{
Expand Down Expand Up @@ -48,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -66,54 +68,33 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: FITSFixedWarning: PLATEID = 7495 / Current plate \n",
"a string value was expected. [astropy.wcs.wcs]\n",
"WARNING:astropy:FITSFixedWarning: PLATEID = 7495 / Current plate \n",
"a string value was expected.\n",
"/Users/ogaz/miniconda3/envs/jdaviz/lib/python3.6/site-packages/glue/viewers/common/viewer.py:179: UserWarning: Add large data set?\n",
" warnings.warn(message)\n"
]
}
],
"outputs": [],
"source": [
"c = cubeviz.CubeViz(filename, vizapp)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "dcd313bd108b42798f0f0998fc4b5244",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Layout(children=[VBox(children=(Layout(children=[Dropdown(layout=Layout(width='10em'), options=('File', 'Load'…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"c.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
96 changes: 59 additions & 37 deletions jdaviz/vizcomponents/applications/cubeviz.py
Expand Up @@ -16,54 +16,76 @@ def __init__(self, filename, vizapp):
#
# Create File Menu
#
self._menu_bar_file = widgets.Dropdown(
options=['File', 'Load', 'Save'],
value='File',
description='',
layout=widgets.Layout(width='10em'),
)
#
# items = [v.ListTile(children=[v.ListTileTitle(children=["Load"])]),
# v.ListTile(children=[v.ListTileTitle(children=["Save"])])]
#
# self._menu_bar_file = v.Layout(children=[v.Menu(offset_y=True,
# children=[v.Btn(slot='activator',
# color='primary',
# children=['File',
# v.Icon(right=True,
# children=['arrow_drop_down'])]),
# v.List(children=items)])
# ])

self._menu_bar_file.observe(self._on_change_menu_bar_file)
self.tile_load = v.ListTile(children=[v.ListTileTitle(children=["Load"])])
self.tile_save = v.ListTile(children=[v.ListTileTitle(children=["Save"])])
self.tile_load.on_event('click', self._on_change_menu_bar_file)
self.tile_save.on_event('click', self._on_change_menu_bar_file)
self.f_items = [self.tile_load, self.tile_save]

self._menu_bar_file = v.Layout(children=
[v.Menu(offset_y=True,
children=[v.Btn(slot='activator', color='primary',
children=['File', v.Icon(right=True, children=['arrow_drop_down'])]),
v.List(children=self.f_items)])
])

#
# Create Add Viewer Menu
#
self._menu_bar_viewer = widgets.Dropdown(
options=['Add Viewer', '3D Viewer', '1D Viewer'],
value='Add Viewer',
description='',
layout=widgets.Layout(width='10em'),
)
self._menu_bar_viewer.observe(self._on_change_menu_bar_viewer)
self.tile_3d_viewer = v.ListTile(
children=[v.ListTileTitle(children=["3D Viewer"])])
self.tile_1d_viewer = v.ListTile(
children=[v.ListTileTitle(children=["1D Viewer"])])
self.tile_3d_viewer.on_event('click', self._on_change_menu_bar_viewer)
self.tile_1d_viewer.on_event('click', self._on_change_menu_bar_viewer)
self.v_items = [self.tile_3d_viewer, self.tile_1d_viewer]


self._menu_bar_viewer = v.Layout(children=
[v.Menu(offset_y=True,
children=[v.Btn(slot='activator', color='primary',
children=['Add Viewer', v.Icon(right=True, children=['arrow_drop_down'])]),
v.List(children=self.v_items)])
])

# Add to menu bar
self._menu_bar = v.Layout(children=[self._menu_bar_file, self._menu_bar_viewer])
self._menu_bar = v.Layout(row=True, wrap=True, children=[
v.Flex(xs6=True, class_='px-2', children=[self._menu_bar_file]),
v.Flex(xs6=True, class_='px-2', children=[self._menu_bar_viewer]),
])

self._menu_bar.box_style = 'success'

self._v1d = Viewer1D(self._vizapp)
self._v3d = ViewerND(self._vizapp)

# this is the line where we would put ipyvutify
self._main_box = v.Layout(children=[widgets.VBox([self._menu_bar, widgets.HBox([self._v3d.show(), self._v1d.show()])])])
#self._main_box = v.Layout(children=[self._menu_bar, self._v3d.show(), self._v1d.show()])

def _on_change_menu_bar_file(self, change):
print(change)

def _on_change_menu_bar_viewer(self, change):
print(change)
self._main_box = v.Layout(row=True, wrap=True, children=[
v.Flex(xs12=True, class_='px-2', children=[self._menu_bar]),
v.Flex(xs6=True, class_='px-2', children=[self._v3d.show()]),
v.Flex(xs6=True, class_='px-2', children=[self._v1d.show()]),
])

def _on_change_menu_bar_file(self, widget, event, data):
with open("/tmp/bob.log", "a") as f:
f.write(str(event) + ' ' + str(widget.children[0].children[0]) + '\n')
f.flush()

def _on_change_menu_bar_viewer(self, widget, event, data):
with open("/tmp/bob.log", "a") as f:
f.write(str(event) + ' ' + widget.children[0].children[0] + '\n')
f.flush()

if widget.children[0].children[0] == '3D Viewer':
# Right now with ipyvuetify the list = list + [new] is the only
# appending syntax that will update the view
self._main_box.children = self._main_box.children + \
[v.Flex(xs6=True, classw='px-2', children=[ViewerND(self._vizapp).show()])]

elif widget.children[0].children[0] == '1D Viewer':
# Right now with ipyvuetify the list = list + [new] is the only
# appending syntax that will update the view
self._main_box.children = self._main_box.children + \
[v.Flex(xs6=True, classw='px-2', children=[Viewer1D(self._vizapp).show()])]

def show(self):
return self._main_box
Expand Down

0 comments on commit 91695f4

Please sign in to comment.