def __init__(self, url=''):
self.file_pickers = []
if url:
o = urlparse(url)
query = parse_qs(o.query)
pwd, = query.get('pwd', [''])
for fname in query.get('files', []):
self.file_pickers.append(FilePicker(pwd, os.path.join(pwd, fname)))
for fpath in query.get('folders', []):
self.file_pickers.append(FilePicker(fpath))
if not self.file_pickers:
self.file_pickers.append(FilePicker())
# Define load action.
self._load_button = ipywidgets.Button(description="load these files")
self._load_button.on_click(self._handle_load)
self._file_tab_button = ipywidgets.Button(description="add tab")
self._file_tab_button.on_click(self._handle_new_tab)
self._subplots = ipywidgets.RadioButtons(description='subplots',
options=[1, 2])
self._subplots.observe(self._handle_nplots, names='value')
# Plot action button.
self._plot_button = ipywidgets.Button(description="Plot my cube")
self._plot_button.on_click(self._goplot)
# Configure layout of the Explorer.
self._plot_container = ipywidgets.Box()
# Define a Tab container for the main controls in the browse interface.
children = [fp.box for fp in self.file_pickers]
self.ftabs = ipywidgets.Tab(children=children)
children = [self._load_button, self._file_tab_button]
self.bbox = ipywidgets.HBox(children=children)
children = [self.ftabs, self.bbox]
self._file_picker_tabs = ipywidgets.Box(children=children)
# Define the plot controls, start with 1 (self._subplots default)
self.plot_controls = [PlotControl()]
pcc_children = [pc.box for pc in self.plot_controls]
self._plot_control_container = ipywidgets.Tab(children=pcc_children)
self._plot_control_container.set_title(0, 'Plot Axes 0')
# Define an Accordian for files, subplots and plots
acc_children = [self._file_picker_tabs, self._subplots,
self._plot_control_container]
self._accord = ipywidgets.Accordion(children=acc_children)
self._accord.set_title(0, 'Files')
self._accord.set_title(1, 'SubPlots')
self._accord.set_title(2, 'Plots')
# Initialise cubes container
self._cubes = []
# Display the browse interface.
IPython.display.display(self._accord)
IPython.display.display(self._plot_button)
IPython.display.display(self._plot_container)
评论列表
文章目录