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

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

项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super().__init__(*args,
                         default_width=640,
                         default_height=480,
                         **kwargs)
        self.switcher = NeovimBufferBar()
        self.set_titlebar(Gtk.HeaderBar(show_close_button=True,
                                        custom_title=self.switcher))
        vbox = Gtk.Box(parent=self, orientation=Gtk.Orientation.VERTICAL)
        self.notebook = NeovimTabBar(parent=vbox)
        self.viewport = NeovimViewport(parent=Gtk.ScrolledWindow(parent=vbox))
        self.terminal = NeovimTerminal(parent=self.viewport, expand=True)
        self.terminal.connect('child-exited', lambda *_:
                              self.close())
        self.terminal.connect('nvim-attached', lambda _, nvim:
                              self.emit('nvim-setup', nvim))
项目:Ebook-Viewer    作者:michaldaniel    | 项目源码 | 文件源码
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(False)

        try:
            self.set_has_subtitle(True)
        except AttributeError:
            pass # Too bad?

        # Set default window title
        self.props.title = _("Preferences")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar()
项目:fpi    作者:solus-cold-storage    | 项目源码 | 文件源码
def headerbar(self):
        header = Gtk.HeaderBar()
        header.set_show_close_button(True)

        self.stack_switcher = Gtk.StackSwitcher()
        header.set_custom_title(self.stack_switcher)
        self.stack_switcher.set_stack(self.stack)
        return header
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, app, window):
        self.app = app
        self.window = window
        Gtk.HeaderBar.__init__(self)
        self.generate()
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, window):
        self.parent = window

        self.selected_logo = None
        self.step = 1
        self.account_image = Gtk.Image(xalign=0)
        self.secret_code = Gtk.Entry()
        self.name_entry = Gtk.Entry()
        self.hb = Gtk.HeaderBar()

        self.generate_window()
        self.generate_components()
        self.generate_header_bar()
项目:PyIDE    作者:raggesilver    | 项目源码 | 文件源码
def __init__(self):
        super(WelcomeWindow, self).__init__()

        self.hb = Gtk.HeaderBar()
        self.hb.set_show_close_button(True)
        self.hb.set_title("Py IDE")
        self.set_titlebar(self.hb)

        self.currentPage = None
        self.hbButtons = []

        self.language = ''

        self.showHome()

        ##################################################################


        self.set_size_request(800, 400)
        self.set_resizable(False)

        self.loadSettings()

        self.connect('destroy', Gtk.main_quit)

        self.show_all()

        Gtk.main()
项目:Ebook-Viewer    作者:michaldaniel    | 项目源码 | 文件源码
def __init__(self, window):
        """
        Provides
        :param window: Main application window reference, serves as communication hub
        """
        super(Gtk.HeaderBar, self).__init__()
        self.set_show_close_button(True)
        # Set default window title
        self.props.title = _("Easy eBook Viewer")
        self.__window = window
        self.__menu = Gtk.Menu()
        # Fill it with all the wigets
        self.__populate_headerbar()
        self.job_running = False
项目:dri-config    作者:TingPing    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super().__init__(
            default_width=800,
            default_height=400,
            **kwargs
        )
        self.add_dialog = None


        action = Gio.SimpleAction.new('add-application', None)
        self.add_action(action)
        action.connect('activate', self.on_add_application)


        header = Gtk.HeaderBar(show_close_button=True, title=_('DRI Configuration'))
        add_btn = Gtk.Button.new_from_icon_name('list-add-symbolic', Gtk.IconSize.BUTTON)
        add_btn.props.action_name = 'win.add-application'
        header.pack_start(add_btn)
        header.show_all()
        self.set_titlebar(header)

        box = Gtk.Box(Gtk.Orientation.HORIZONTAL)
        sidebar = Gtk.StackSidebar()
        sw = Gtk.ScrolledWindow(child=sidebar, hscrollbar_policy=Gtk.PolicyType.NEVER)
        box.pack_start(sw, False, True, 0)

        stack = Gtk.Stack()
        # Just a basic mockup
        conf = dri.DRIConfig('/etc/drirc')
        device = conf.devices[0]
        for app in device.apps:
            # TODO: Group these by device
            pane = ApplicationPane(app, visible=True)
            stack.add_titled(pane, app.name, app.name)
        sidebar.props.stack = stack

        sw = Gtk.ScrolledWindow(child=stack)
        box.pack_start(sw, True, True, 0)
        box.show_all()
        self.add(box)
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self):
        Gtk.HeaderBar.__init__(self)

        self.set_show_close_button(True)
        self.props.title = "PyFlowChart"

        self.info_box = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL)

        self.file_button = Gtk.Button.new_from_icon_name("open-menu-symbolic", ICONSIZE)

        self.settings_button = Gtk.Button.new_from_icon_name("preferences-system", ICONSIZE)
        self.help_button = Gtk.Button.new_from_icon_name("help-about", ICONSIZE)

        self.main_menu = self.init_main_menu()
        self.settings_menu = self.init_settings_menu()
        self.help_menu = self.init_help_menu() 
        #self.init_edit_menu()

        self.file_button.connect('clicked', self.file_clicked)
        self.settings_button.connect('clicked', self.settings_clicked)
        self.help_button.connect('clicked', self.help_clicked)

        self.info_box.add(self.settings_button)
        self.info_box.add(self.help_button)

        self.pack_start(self.file_button) 
        self.pack_end(self.info_box)

        self.buttons = []
        # self.populate_buttons() 

        self.show_all()
项目:impress-writer    作者:CSEC-NITH    | 项目源码 | 文件源码
def __init__(self):

#########Setting_Basic_Window_Size&Border########################################

        Gtk.Window.__init__(self,title="Impress Writer")
        self.set_border_width(1)
        self.set_default_size(1366,768)

###################Header_Bar###################################################

        hb=Gtk.HeaderBar()
        hb.set_show_close_button(True)
        hb.props.title="Impress Writer"
        self.set_titlebar(hb)

#############################Adding_Overall_Grid################################

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

###################Adding_Toolbar############################################

        self.create_toolbar_top()

###########Adding_TextView#################################################

        self.text_grid = Gtk.Grid()        
        self.create_main_view()
        self.create_textview()
        self.create_toolbar()
        self.create_buttons()

#############Adding synonyms flowbox######################################

        self.create_synonyms_flowbox()
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def _on_button_clicked(self, button):
        dialog = Gtk.Dialog()
        dialog.set_transient_for(self)

        gpaste_settings = GPaste.SettingsUiWidget()

        for child in gpaste_settings.get_children():
            if isinstance(child, Gtk.StackSwitcher):
                toplevel = dialog.get_toplevel()
                if not toplevel: continue

                gpaste_settings.remove(child)

                header_bar = Gtk.HeaderBar()
                header_bar.set_show_close_button(True)
                header_bar.set_title(None)
                header_bar.set_subtitle(None)
                header_bar.set_custom_title(child)

                toplevel.set_titlebar(header_bar)

            if isinstance(child, Gtk.Stack):
                child.set_transition_type(
                    Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
                )
                child.set_transition_duration(self._transition_duration)

        content_area = dialog.get_content_area()
        content_area.add(gpaste_settings)

        dialog.show_all()
        dialog.run()
        dialog.destroy()
项目:MTodo    作者:mortezaipo    | 项目源码 | 文件源码
def __init__(self, title: str, subtitle: str, buttons: dict):
        """Initialize HeaderBar class"""
        self._widget = Gtk.HeaderBar()
        self._widget.set_show_close_button(True)
        self._widget.props.title = title
        self._widget.set_subtitle(subtitle)
        if buttons:
            for button, position in buttons.items():
                if position == "left":
                    self._widget.pack_start(button.render)
                elif position == "right":
                    self._widget.pack_end(button.render)
项目:MTodo    作者:mortezaipo    | 项目源码 | 文件源码
def __init__(self, name: str, title: str, subtitle: str, width: int, height: int, header_buttons: dict, is_parent: bool):
        """Initialize Window class"""
        super(Window, self).__init__(title=title)
        self._name = name
        self._title = title
        self._subtitle = subtitle
        self._width = width
        self._height = height
        if header_buttons:
            self._header = HeaderBar(self._title, self._subtitle, header_buttons)
            self.set_titlebar(self._header.render)
        else:
            self._header = None
        self._is_parent = is_parent

        # self.set_resizable(False)
        self.set_size_request(self._width, self._height)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_border_width(10)
        self.set_name(self._name)

        self._scrolled = Gtk.ScrolledWindow()
        self._scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
        self._box.set_homogeneous(False)
        self.add(self._scrolled)
        self._scrolled.add(self._box)

        if self._is_parent:
            self.connect("delete-event", Gtk.main_quit)
项目:shadowsocks-eos    作者:Simpleyyt    | 项目源码 | 文件源码
def __init__(self, app, *args, **kwargs):
        super(Gtk.Window, self).__init__(*args, **kwargs)
        self.app = app
        headerbar = Gtk.HeaderBar()
        headerbar.props.show_close_button = True
        headerbar.set_title('?????')
        self.set_titlebar(headerbar)
        self.connect('delete-event', self.delete_event)
        self.build_ui()

        self.props.resizable = False
        self.set_size_request (640, 480)
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def build_headerbar(title, name, close_button):

    headerbar = Gtk.HeaderBar(name=name, title=title)
    if close_button == 1: headerbar.set_show_close_button(True)
    else: headerbar.set_show_close_button(False)
    return headerbar
项目:nautilus-folder-icons    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def _build_header_bar(self):
        """Setup window headerbar."""
        # Header bar
        headerbar = Gtk.HeaderBar()
        headerbar_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                      spacing=3)

        title = Gtk.Label()
        title.set_text(_("Icon Chooser"))
        title.get_style_context().add_class("title")
        headerbar_container.pack_start(title, False, False, 0)

        subtitle = Gtk.Label()
        subtitle.get_style_context().add_class("subtitle")
        subtitle_text = ", ".join(self._folders)
        subtitle.set_text(subtitle_text)
        subtitle.set_ellipsize(Pango.EllipsizeMode.END)
        subtitle.set_tooltip_text(subtitle_text)
        subtitle.props.max_width_chars = 30
        headerbar_container.pack_start(subtitle, False, False, 0)

        headerbar.set_custom_title(headerbar_container)
        headerbar.set_show_close_button(False)

        # Search Button
        self._search_btn = Gtk.ToggleButton()
        search_icn = Gio.ThemedIcon(name="system-search-symbolic")
        search_img = Gtk.Image.new_from_gicon(search_icn, Gtk.IconSize.BUTTON)
        self._search_btn.set_image(search_img)

        # Cancel Button
        cancel_button = Gtk.Button()
        cancel_button.set_label(_("Cancel"))
        cancel_button.connect("clicked", self.close_window)

        headerbar.pack_start(cancel_button)
        headerbar.pack_end(self._search_btn)
        self.set_titlebar(headerbar)
项目:revolt    作者:aperezdc    | 项目源码 | 文件源码
def __make_headerbar(self):
        header = Gtk.HeaderBar()
        header.set_show_close_button(True)
        header.get_style_context().add_class("revolt-slim")
        spinner = Gtk.Spinner()
        header.pack_end(spinner)
        self.bind_property("network-busy", spinner, "active",
                           GObject.BindingFlags.DEFAULT)
        header.show_all()
        return header
项目:efibootmgr-gui    作者:Elinvention    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Window.__init__(self, title="EFI boot manager")
        self.set_border_width(10)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)

        self.store = EFIStore(self)
        self.tree = Gtk.TreeView(self.store, vexpand=True)
        vbox.add(self.tree)

        renderer_text = Gtk.CellRendererText()
        renderer_check = Gtk.CellRendererToggle(radio=False)
        renderer_radio = Gtk.CellRendererToggle(radio=True)
        renderer_check.connect("toggled", self.store.change_active)
        renderer_radio.connect("toggled", self.store.change_boot_next)
        self.tree.append_column(Gtk.TreeViewColumn("BootNum", renderer_text, text=0))
        self.tree.append_column(Gtk.TreeViewColumn("Name", renderer_text, text=1))
        self.tree.append_column(Gtk.TreeViewColumn("Loader", renderer_text, text=2))
        self.tree.append_column(Gtk.TreeViewColumn("Active", renderer_check, active=3))
        self.tree.append_column(Gtk.TreeViewColumn("NextBoot", renderer_radio, active=4))
        for column in self.tree.get_columns():
            column.set_resizable(True)
            column.set_min_width(75)

        hb = Gtk.HeaderBar()
        hb.set_show_close_button(True)
        hb.props.title = "EFI boot manager"
        self.set_titlebar(hb)

        clear_btn = btn_with_icon("edit-clear-all-symbolic")
        clear_btn.connect("button-press-event", self.discard_changes)
        hb.pack_end(clear_btn)

        write_btn = btn_with_icon("document-save-symbolic")
        write_btn.connect("button-press-event", self.apply_changes)
        hb.pack_end(write_btn)

        hbox = Gtk.HButtonBox()
        hbox.set_layout(Gtk.ButtonBoxStyle.EXPAND)
        vbox.add(hbox)
        up = btn_with_icon("go-up-symbolic")
        down = btn_with_icon("go-down-symbolic")
        new = btn_with_icon("list-add-symbolic")
        delete = btn_with_icon("list-remove-symbolic")
        hbox.add(up)
        hbox.add(down)
        hbox.add(new)
        hbox.add(delete)
        up.connect("button-press-event", self.up)
        down.connect("button-press-event", self.down)
        new.connect("button-press-event", self.new)
        delete.connect("button-press-event", self.delete)

        self.connect("delete-event", self.quit)
        self.set_default_size(300, 260)