Python ipywidgets 模块,Box() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用ipywidgets.Box()

项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def __init__(self):
        from .docker import DockerConfig
        from .interfaces import InterfaceStatus
        from .visualization import MdtExtensionConfig

        self.interface_status = InterfaceStatus()
        self.compute_config = DockerConfig()
        self.nbextension_config = MdtExtensionConfig()
        self.changelog = ChangeLog()
        self.tab_list = StyledTab([ipy.Box(),
                                   self.nbextension_config,
                                   self.interface_status,
                                   self.compute_config,
                                   self.changelog])
        self.tab_list.set_title(0, '^')
        self.tab_list.set_title(1, 'Notebook config')
        self.tab_list.set_title(2, "Interfaces")
        self.tab_list.set_title(3, 'Docker config')
        self.tab_list.set_title(4, "What's new")
        self.children = [self.make_header(), self.tab_list]
        super().__init__(children=self.children)
项目:py-cloud-compute-cannon    作者:Autodesk    | 项目源码 | 文件源码
def __init__(self, file_dict, ignore_ext=None, **kwargs):
        if ignore_ext is None:
            ignore_ext = 'pyo pyc'.split()

        titles = []
        file_list = [ipy.Box()]
        ignores = set(ignore_ext)
        for filename, fileobj in file_dict.items():
            ext = filename.split('.')[-1]
            if ext in ignores:
                continue
            file_display = FileView(filename, fileobj)
            file_list.append(file_display)
            titles.append(filename)
        super(FileBrowser, self).__init__(file_list, **kwargs)
        self.set_title(0, 'x')
        for ititle, title in enumerate(titles):
            self.set_title(ititle + 1, title)
项目:cube_browser    作者:SciTools    | 项目源码 | 文件源码
def __init__(self, initial_value='', default=''):
        if initial_value == '':
            try:
                initial_value = iris.sample_data_path('')
            except ValueError:
                initial_value = ''
        # Define the file system path for input files.
        self._path = ipywidgets.Text(
            description='Path:',
            value=initial_value,
            width="100%")
        # Observe the path.
        self._path.observe(self._handle_path, names='value')
        # Use default path value to initialise file options.
        options = []
        if os.path.exists(self._path.value):
            options = glob.glob('{}/*'.format(self._path.value))
            options.sort()
        default_list = []
        for default_value in default.split(','):
            if default_value in options:
                default_list.append(default_value)
        default_tuple = tuple(default_list)

        # Defines the files selected to be loaded.
        self._files = ipywidgets.SelectMultiple(
            description='Files:',
            options=OrderedDict([(os.path.basename(f), f)
                                 for f in options]),
            value=default_tuple,
            width="100%"
        )
        self.deleter = ipywidgets.Button(description='delete tab',
                                         height='32px', width='75px')
        hbox = ipywidgets.HBox(children=[self._files, self.deleter])
        self._box = ipywidgets.Box(children=[self._path, hbox], width="100%")
项目:cube_browser    作者:SciTools    | 项目源码 | 文件源码
def __init__(self):
        self.mpl_kwargs = {}
        # Defines the cube which is to be plotted.
        self.cube_picker = ipywidgets.Dropdown(description='Cubes:',
                                               options=('None', None),
                                               value=None,
                                               width='50%')

        # Define the type of cube browser plot required
        self.plot_type = ipywidgets.Dropdown(
            description='Plot type:',
            options={'pcolormesh': cube_browser.Pcolormesh,
                     'contour': cube_browser.Contour,
                     'contourf': cube_browser.Contourf},
            value=cube_browser.Pcolormesh)

        self.x_coord = ipywidgets.Dropdown(
            description='X Coord',
            options=('None', None))
        self.y_coord = ipywidgets.Dropdown(
            description='Y Coord',
            options=('None', None))
        self.cmap = ipywidgets.Text(
            description='colour map')

        # Handle events:
        self.cube_picker.observe(self._handle_cube_selection,
                                 names='value')
        self.cmap.observe(self._handle_cmap, names='value')
        self.plot_type.observe(self._handle_plot_type, names='value')

        self._box = ipywidgets.Box(children=[self.cube_picker,
                                             self.plot_type,
                                             self.x_coord,
                                             self.y_coord,
                                             self.cmap])
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def __init__(self):
        self.client = None
        self.warning = ipy.HTML(description='<b>Engine status:</b>', value=SPINNER)
        self.devmode_label = ipy.Label('Use local docker images (developer mode)',
                                       layout=ipy.Layout(width='100%'))
        self.devmode_button = ipy.Checkbox(value=mdt.compute.config.devmode,
                                           layout=ipy.Layout(width='15px'))
        self.devmode_button.observe(self.set_devmode, 'value')

        self.engine_config_description = ipy.HTML('Docker host with protocol and port'
                                                  ' (e.g., <code>http://localhost:2375</code>).'
                                                  ' If blank, this'
                                                  ' defaults to the docker engine configured at '
                                                  'your command line.',
                                                  layout=ipy.Layout(width='100%'))
        self.engine_config_value = ipy.Text('blank', layout=ipy.Layout(width='100%'))
        self.engine_config_value.add_class('nbv-monospace')

        self.image_box = ipy.Box()

        self._reset_config_button = ipy.Button(description='Reset',
                                               tooltip='Reset to applied value')
        self._apply_changes_button = ipy.Button(description='Apply',
                                                tooltip='Apply for this session')
        self._save_changes_button = ipy.Button(description='Make default',
                                               tooltip='Make this the default for new sessions')
        self._reset_config_button.on_click(self.reset_config)
        self._apply_changes_button.on_click(self.apply_config)
        self._save_changes_button.on_click(self.save_config)

        self.children = [self.warning,
                         VBox([self.engine_config_description,
                               self.engine_config_value]),
                         HBox([self._reset_config_button,
                               self._apply_changes_button,
                               self._save_changes_button]),
                         HBox([self.devmode_button, self.devmode_label]),
                         self.image_box]
        self.reset_config()
        super().__init__(children=self.children)
        self.connect_to_engine()
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def __init__(self, paramlist, paramdefs, title=None):
        super(Configurator, self).__init__(layout=ipy.Layout(display='flex',
                                                             flex_flow='column',
                                                             align_self='flex-start',
                                                             align_items='stretch',
                                                             max_width='100%'))
        self.paramlist = paramlist
        self.paramdefs = paramdefs

        self.apply_button = ipy.Button(description='Apply')
        self.apply_button.on_click(self.apply_values)

        self.reset_button = ipy.Button(description='Reset')
        self.reset_button.on_click(self.reset_values)
        self.buttons = ipy.Box([self.reset_button, self.apply_button],
                               layout=ipy.Layout(align_self='center'))

        self.selectors = collections.OrderedDict([(p.name, ParamSelector(p)) for p in paramdefs])
        self.reset_values()

        title = utils.if_not_none(title, 'Configuration')
        self.title = ipy.HTML('<center><h4>%s</h4></center><hr>' % title,
                              align_self='center')

        self.currentconfig = ipy.Textarea(description='<i>Current params</i>',
                                          disabled=True,
                                          value=self._pretty_print_config(),
                                          layout=ipy.Layout(width='350px', min_height='300px',
                                                            max_height='500px',
                                                            display='flex', flex_flow='column'))
        self.middle = HBox([VBox(list(self.selectors.values())), self.currentconfig])
        self.children = [self.title, self.middle, self.buttons]
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def _capture_logging_displays(display=False, **kwargs):
    global _current_tabs, _prev_tabs
    _prev_tabs = _current_tabs
    if widgets_enabled:
        _current_tabs = LoggingTabs(OrderedDict(x=ipy.Box()), display=display,
                                    **wu.process_widget_kwargs(kwargs))
    else:
        _current_tabs = None
        enable_logging_widgets(False)
        print('Failed to create UI logging system. Logging widgets disabled')
项目:notebook-molecular-visualization    作者:Autodesk    | 项目源码 | 文件源码
def __init__(self, mol):
        self.mol = mol

        self.toolpane = VBox()
        self.viewer = self.VIEWERTYPE(mol, width=self.VIEWERWIDTH)

        self.subtools = ipy.Box()
        self.viewer_pane = VBox([self.viewer, self.subtools])
        self.main_pane = HBox([self.viewer_pane, self.toolpane])

        super().__init__([self.main_pane])
项目:omaat    作者:biorack    | 项目源码 | 文件源码
def fileSelector(self):
        """
        :return: An ipython widget containing a file selector. If you simply have this method as the last
                    line of a notebook cell, you'll see it. otherwise you need to do IPython.display.display(fileSelector())
        """
        params = get_default_params()
        arrayed_analysis_default_filename = params['arrayed_analysis_default_filename']
        myFiles = self.getFilelist()
        myFiles.sort()
        myFiles = [path.join(path.basename(path.dirname(p)),path.basename(p)) for p in myFiles]

        fileSelector=ipywidgets.Select(options=myFiles,  height=300,width=600)
        if arrayed_analysis_default_filename in myFiles:
            fileSelector.value = arrayed_analysis_default_filename
        else:
            fileSelector.value=myFiles[0]

        title=ipywidgets.HTML(value="Pick the file you want to load here") #IPN2: HTMLWidget
        #IPython.display.display(title)
        #IPython.display.display(fileSelector)
        def _fileSelector_updated(widget=None):
            if(self.filename!=fileSelector.value):
                self.filename=fileSelector.value
                arrayed_analysis_default_filename = self.filename
                params['arrayed_analysis_default_filename'] = arrayed_analysis_default_filename
                update_default_params(params)
        try:
            fileSelector.observe(_fileSelector_updated)
        except AttributeError:
            fileSelector.on_trait_change(_fileSelector_updated)
        _fileSelector_updated()
        return ipywidgets.Box(children=(title,fileSelector))
项目:yuuno    作者:Irrational-Encoding-Wizardry    | 项目源码 | 文件源码
def _default__children(self):
        box = Box([self.image_widget], layout=self.layouts['image'])
        return box, self.html_widget
项目:cube_browser    作者:SciTools    | 项目源码 | 文件源码
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)