Python gi.repository.Gtk 模块,Notebook() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用gi.repository.Gtk.Notebook()

项目:gedit-jshint    作者:Meseira    | 项目源码 | 文件源码
def __init__(self):
        #self._widget = Gtk.Notebook()
        self._widget = Gtk.Label("Configuration panel for JSHint Plugin")

        #grid = Gtk.Grid()
        #for i in range(30):
        #    button = Gtk.CheckButton("Button {}".format(i))
        #    button.set_tooltip_text("This is the button {}".format(i))
        #    grid.attach(button, i // 10, i % 10, 1, 1)
        #self._widget.append_page(grid, Gtk.Label("Enforcing"))

        #page = Gtk.Box()
        #page.add(Gtk.Label("Relaxing options"))
        #self._widget.append_page(page, Gtk.Label("Relaxing"))

        #page = Gtk.Box()
        #page.add(Gtk.Label("Environments options"))
        #self._widget.append_page(page, Gtk.Label("Environments"))
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, datadir):
        Gtk.Window.__init__(self)
        self.icons = stock.EditorIconFactory(self, datadir)
        self.connect('destroy', lambda w: Gtk.main_quit())
        self.g_help_window = None
        # toplevel_vbox:
        #   -menubar
        #   -toolbar
        #   -notebook
        #   -statusbar
        self.toplevel_vbox = Gtk.VBox()
        self.add(self.toplevel_vbox)
        self.create_menu_and_toolbar()
        self.g_notebook = Gtk.Notebook()
        self.toplevel_vbox.pack_start(self.g_notebook, True, True, 0)
        self.vbox = Gtk.VBox()
        self.toplevel_vbox.pack_start(self.vbox, True, True, 0)
        self.create_mainwin_ui()
        self.show_all()
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def setup_window(self):
        self.menubar = controlBar() 
        self.set_titlebar(self.menubar)

        self.connect_control_buttons()

        self.edit_menu = dataMenu() 
        self.add_menu = addMenu()

        self.connect_menu_buttons()

        main_grid = Gtk.Grid()
        self.add(main_grid)

        main_grid.attach(self.menubar, 0, 0, 1, 1)

        self.interface_switcher = Gtk.Notebook()
        self.interface_switcher.set_show_tabs(False)
        main_grid.attach(self.interface_switcher, 0, 1, 1, 1)
        self.setup_viewer()
        self.setup_builder()
项目:duck-feed    作者:h0m3stuck    | 项目源码 | 文件源码
def __init__(self, builder, feed_manager):
        self.builder = builder
        self.feed_manager = feed_manager
        self.box = builder.get_object('box')
        self.notebook = Gtk.Notebook()

        self.box.add(self.notebook)
        self.notebook.show()

        thread = threading.Thread(target=self.load_feeds)
        thread.daemon = True
        thread.start()
项目:mama    作者:maateen    | 项目源码 | 文件源码
def __init__(self, app):
        Gtk.Window.__init__(self, title="Mama Manager", application=app)
        self.set_default_size(800, 400)
        self.set_resizable(True)
        self.set_border_width(0)
        self.get_focus()
        self.set_position(Gtk.WindowPosition.CENTER)
        path = os.path.dirname(os.path.abspath(__file__)).strip('librairy')
        self.icon_path = path + 'resources/icons/'
        self.set_default_icon_from_file(path + '/resources/icons.png')

        # get two button to switch between view
        setup_icon = Gtk.Image()
        setup_icon.set_from_file(self.icon_path + 'setup.png')
        button_config = Gtk.ToolButton(icon_widget=setup_icon)
        button_config.set_label("Setup")
        button_config.set_is_important(True)
        button_config.set_tooltip_text('Open setup window')
        button_config.show()
        button_config.connect("clicked", self.change_page, 1)

        button_back = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        button_back.connect("clicked", self.change_page, 0)
        button_cancel = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.change_page, 0)

        # get the main view
        content = AddWindow(button_config)
        label_main = Gtk.Label("main")
        config = SetupWindow(button_back, button_cancel)
        label_config = Gtk.Label("config")

        # create a Gtk.Notebook to store both page
        self.notebook = Gtk.Notebook.new()
        self.notebook.set_show_tabs(False)
        self.notebook.append_page(content.get_grid(), label_main)
        self.notebook.append_page(config.getGrid(), label_config)

        # show
        self.add(self.notebook)
        self.show_all()
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.config = kwargs.pop("config", None)
        self.sbrick_communications_store = ObservingDict(dict())

        Gtk.ApplicationWindow.__init__(self, *args, **kwargs)

        # self.set_default_size(800, 480)
        self.resize(800, 480)
        self.connect("delete-event", self.on_delete_window)

        self.notebook = Gtk.Notebook()
        self.add(self.notebook)
        self.notebook.set_scrollable(True)

        if self.config is not None:
            for sbrick in self.config:
                page = SBrickBox(sbrick, self.sbrick_communications_store)
                page.connect("show_message", self.on_show_message)
                self.notebook.append_page(page, Gtk.Label(sbrick["name"]))

        self.sequences_box = SequencesBox(self.config, self.sbrick_communications_store)
        self.notebook.append_page(self.sequences_box, Gtk.Label("Sequences"))

        self.actions = []
        self.actions_connected = []

        self.setup_actions()
        self.show_all()

        # noinspection PyUnusedLocal
项目:GPU-Viewer    作者:arunsivaramanneo    | 项目源码 | 文件源码
def __init__(self, title):
        super(MyGtk, self).__init__(title=title)
        self.set_icon_from_file(Const.APP_LOGO_PNG)
        self.notebook = Gtk.Notebook()
        self.add(self.notebook)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def get_test_gtk3_viewmanager():
    from gi.repository import Gtk
    from softwarecenter.ui.gtk3.session.viewmanager import (
        ViewManager, get_viewmanager)
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def get_test_gtk3_viewmanager():
    from gi.repository import Gtk
    from softwarecenter.ui.gtk3.session.viewmanager import (
        ViewManager, get_viewmanager)
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def get_test_gtk3_viewmanager():
    from gi.repository import Gtk
    from softwarecenter.ui.gtk3.session.viewmanager import (
        ViewManager, get_viewmanager)
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, content, msg=""):
        Gtk.Notebook.__init__(self)
        self._last_timeout_id = None
        self.spinner_view = SpinnerView(msg)
        # its critical to show() the spinner early as otherwise
        # gtk_notebook_set_active_page() will not switch to it
        self.spinner_view.show()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.set_show_tabs(False)
        self.set_show_border(False)
        self.append_page(content, Gtk.Label("content"))
        self.append_page(self.spinner_view, Gtk.Label("spinner"))
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, content, msg=""):
        Gtk.Notebook.__init__(self)
        self._last_timeout_id = None
        self.spinner_view = SpinnerView(msg)
        # its critical to show() the spinner early as otherwise
        # gtk_notebook_set_active_page() will not switch to it
        self.spinner_view.show()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.set_show_tabs(False)
        self.set_show_border(False)
        self.append_page(content, Gtk.Label("content"))
        self.append_page(self.spinner_view, Gtk.Label("spinner"))
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def detach_tab(self, notebook, page_content, x, y):

        def remove_additional_page(notebook, page_content, page_num, window):
            self.detached_tabs_names.remove(page_content.get_name())
            if notebook.get_n_pages() == 0:
                self.additional_windows_list.remove(window)
                window.destroy()

        def additional_window_destroyed(window, event, notebook):
            if notebook.get_n_pages() != 0:
                for i in range(notebook.get_n_pages()):
                    self.detached_tabs_names.remove(notebook.get_nth_page(i).get_name())
                    notebook.remove_page(i)
            window.remove(notebook)
            self.additional_windows_list.remove(window)

        tab_label = notebook.get_tab_label(page_content)

        additional_window = Gtk.Window(
            title = "Games Nebula",
            type = Gtk.WindowType.TOPLEVEL,
            window_position = Gtk.WindowPosition.CENTER,
            default_width = 800,
            default_height = 600,
            icon = app_icon,
            )
        additional_window.connect('key-press-event', self.shortcuts)
        self.additional_windows_list.append(additional_window)

        workarea_width, workarea_height = self.get_monitor_workarea(additional_window)
        additional_window.set_property('default_width', workarea_width)
        additional_window.set_property('default_height', workarea_height)

        additional_notebook = Gtk.Notebook(
            show_tabs = self.show_tabs
            )
        additional_notebook.set_group_name('games_nebula')
        self.additional_notebooks_list.append(additional_notebook)
        additional_window.add(additional_notebook)

        additional_notebook.connect('create-window', self.detach_tab)
        additional_notebook.connect('page-removed', remove_additional_page, additional_window)
        additional_window.connect('delete-event', additional_window_destroyed, additional_notebook)

        additional_window.show_all()

        notebook.detach_tab(page_content)
        additional_notebook.append_page(page_content, tab_label)
        additional_notebook.set_tab_detachable(page_content, True)
        additional_notebook.set_tab_reorderable(page_content, True)

        self.detached_tabs_names.append(page_content.get_name())
项目:emoji-keyboard    作者:OzymandiasTheGreat    | 项目源码 | 文件源码
def __init__(self):

        Gtk.Window.__init__(
            self, title='Pick emoji',
            accept_focus=False,
            skip_taskbar_hint=True)
        self.set_keep_above(True)
        self.set_icon_name(shared.icon)
        self.set_type_hint(Gdk.WindowTypeHint.UTILITY)
        self.set_border_width(6)
        if shared.settings['keyboard_use_compact']:
            self.set_default_size(*shared.settings['keyboard_size_compact'])
        else:
            self.set_default_size(*shared.settings['keyboard_size_full'])
        self.connect('show', self.window_shown)
        self.connect('delete-event', self.hide_window)
        self.connect('configure-event', self.window_resized)

        self.notebook = Gtk.Notebook()
        self.add(self.notebook)

        self.emoji_views = []
        for category in shared.categories:
            scrolled_window = Gtk.ScrolledWindow()
            model = shared.emoji.categories[category]
            page = Gtk.IconView.new_with_model(model)
            page.set_selection_mode(Gtk.SelectionMode.NONE)
            page.set_activate_on_single_click(True)
            page.connect('item-activated', self.paste_emoji)
            page.set_pixbuf_column(0)
            page.set_tooltip_column(1)
            self.emoji_views.append(page)
            scrolled_window.add(page)
            label = Gtk.Box(spacing=2)
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(os.path.join(
                shared.data_dir,
                'category-icons',
                shared.categories[category] + '.svg'),
                16, 16, True)
            image = Gtk.Image.new_from_pixbuf(pixbuf)
            text = Gtk.Label(shared.categories[category].title())
            label.pack_start(image, True, True, 0)
            label.pack_start(text, True, True, 0)
            image.show()
            if shared.settings['keyboard_use_compact']:
                page.set_columns(shared.settings['keyboard_columns_compact'])
            else:
                page.set_columns(shared.settings['keyboard_columns_full'])
                text.show()
            self.notebook.append_page(scrolled_window, label)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, teacher, no_notebook=False):
        Gtk.VBox.__init__(self)
        cfg.ConfigUtils.__init__(self, teacher.m_exname)
        assert type(no_notebook) == bool
        self._std_buttons = []
        self.m_key_bindings = {}
        self.m_t = teacher

        vbox = Gtk.VBox()
        vbox.set_spacing(gu.PAD)
        vbox.set_border_width(gu.PAD)
        vbox.show()

        self.practise_box = Gtk.VBox()
        self.practise_box.show()
        vbox.pack_start(self.practise_box, True, True, 0)

        box = Gtk.VBox()
        self.practise_box.pack_start(box, False, False, padding=gu.hig.SPACE_LARGE)
        box.show()
        self.g_lesson_heading = Gtk.Label()
        box.pack_start(self.g_lesson_heading, True, True, 0)

        self.g_lesson_description = Gtk.Label()
        self.g_lesson_description.set_line_wrap(True)
        box.pack_start(self.g_lesson_description, True, True, 0)

        self.action_area = Gtk.HBox()
        self.action_area.show()
        vbox.pack_start(self.action_area, False, False, 0)

        self.config_box = Gtk.VBox()
        self.config_box.set_border_width(gu.PAD)
        self.config_box.show()
        self.config_box_sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        if no_notebook:
            self.pack_start(vbox, True, True, 0)
            self.pack_start(self.config_box, False, False, 0)
            self.g_notebook = None

        else:
            self.g_notebook = Gtk.Notebook()
            self.pack_start(self.g_notebook, True, True, 0)

            self.g_notebook.append_page(vbox, Gtk.Label(label=_("Practise")))
            self.g_notebook.append_page(self.config_box, Gtk.Label(label=_("Config")))
            self.g_notebook.show()
        self.g_cancel_test = Gtk.Button(_("_Cancel test"))
        self.g_cancel_test.connect('clicked', self.on_cancel_test)
        self.action_area.pack_end(self.g_cancel_test, False, False, 0)
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, parent, courses, user):
        Gtk.Dialog.__init__(self, "Preferences", parent,
            0, (Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        self.set_size_request(400, -1)
        self.planned_ges = courses  

        self.ge_list = [
                'A1', 'A2', 'A3', 
                'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 
                'C1', 'C2', 'C3', 'C4', 'C5', 
                'D1', 'D2', 'D3', 'D4/E', 'D5', 
                'F'
                ]

        self.ge_length = len(self.ge_list)

        self.notebook = Gtk.Notebook()
        self.box = self.get_content_area()
        self.box.add(self.notebook)

        self.user = Gtk.Grid()
        self.user.set_column_homogeneous(True)
        self.user.attach(Gtk.Label("Year:"), 0, 0, 1, 1)

        self.year_selector = Gtk.ComboBoxText()
        self.user.attach(self.year_selector, 1, 0, 1, 1)
        for x in range(1,7):
            self.year_selector.append_text(str(x))
        self.year_selector.set_active(user['year']-1)

        self.user.attach(Gtk.Label("Years to display:"), 0, 1, 1, 1)
        self.display_years_selector = Gtk.ComboBoxText()
        self.user.attach(self.display_years_selector, 1, 1, 1, 1)
        for x in range(1,7):
            self.display_years_selector.append_text(str(x))
        self.display_years_selector.set_active(user['display_years']-1)

        self.notebook.append_page(self.user, Gtk.Label("User Info"))

        self.ges = Gtk.Grid()
        self.ges.set_column_homogeneous(True)

        for pos, ge in enumerate(self.ge_list):
            self.ges.attach(Gtk.Label(ge), 0, pos, 1, 1)
            if ge in self.planned_ges:
                self.ges.attach(editable_label(self.planned_ges[ge]), 1, pos, 1, 1)
            else:
                self.ges.attach(editable_label(), 1, pos, 1, 1)

        self.notebook.append_page(self.ges, Gtk.Label("GEs"))

        self.show_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, cache, db, distro, icons, datadir, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
                            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.datadir = datadir
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, cache, db, distro, icons, datadir, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
                            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.datadir = datadir
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None