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

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

项目:py-cloud-compute-cannon    作者:Autodesk    | 项目源码 | 文件源码
def update(self, *args):
        jobstat = self._job.status
        status_display = StatusView(self._job)
        if self._job.inputs:
            input_browser = FileBrowser(self._job.inputs, margin=5, font_size=9)
        else:
            input_browser = ipy.HTML('No input files')
        file_browser = ipy.Tab([input_browser])
        file_browser.set_title(0, 'Input files')

        if jobstat == status.FINISHED:
            output_files = self._job.get_output()
            if self._job.stdout:
                output_files['Standard output'] = self._job.stdout
            if self._job.stderr:
                output_files['Standard error'] = self._job.stderr
            output_browser = FileBrowser(output_files, margin=5, font_size=9)
            file_browser.children = [input_browser, output_browser]
            file_browser.set_title(1, 'Output files')
            self.children = [status_display, file_browser]

        else:
            update_button = ipy.Button(description='Update')
            update_button.on_click(self.update)
            self.children = [status_display, update_button, file_browser]
项目:cube_browser    作者:SciTools    | 项目源码 | 文件源码
def _update_filepickers(self):
        children = [fp.box for fp in self.file_pickers]
        for i, child in enumerate(children):
            fp.deleter.index = i
            fp.deleter.on_click(self._handle_delete_tab)
        self.ftabs = ipywidgets.Tab(children=children)
        self._file_picker_tabs.children = [self.ftabs, self.bbox]
项目:snowballing    作者:JoaoFelipe    | 项目源码 | 文件源码
def __init__(self, querier, citation_var, citation_file=None, debug=False, start=None, load=True):
        from .selenium_scholar import URLQuery
        reload()
        self.querier = querier
        work = work_by_varname(citation_var)
        citation_file = citation_file or getattr(work, "citation_file", citation_var)
        self.navigator = ArticleNavigator(citation_var, citation_file, backward=False, force_citation_file=False)
        self.query = URLQuery(self.navigator.work.scholar, start)
        self.next_page_widget = Button(description='Next Page', icon='fa-arrow-right')
        self.reload_widget = Button(description='Reload', icon='fa-refresh')
        self.previous_page_widget = Button(description='Previous Page', icon='fa-arrow-left')
        self.debug_widget = ToggleButton(value=debug, description="Debug")
        self.page_number_widget = Label(value="")
        self.next_page_widget.on_click(self.next_page)
        self.reload_widget.on_click(self.reload)
        self.previous_page_widget.on_click(self.previous_page)

        self.view = Tab([
            VBox([
                HBox([
                    self.previous_page_widget,
                    self.reload_widget,
                    self.next_page_widget,
                    self.debug_widget,
                    self.page_number_widget
                ]),
                self.navigator.output_widget,
            ]),
            self.navigator.view
        ])
        self.view.set_title(0, "Page")
        self.view.set_title(1, "Article")
        if load:
            self.reload(None)
项目: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)