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

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

项目: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()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def undo_all(self, toolbutton):
        try:
            gv.ucib.stop_engine()
            gv.uciw.stop_engine()
        except:
            pass
        self.gameover = False
        while len(self.movelist) != 0:
            self.undo_move()
        self.lastmove = ""

        self.stm = self.get_side_to_move()
        gv.gui.set_side_to_move(self.stm)

        gv.board.update()
        # set move list window to initial position
        self.move_list.set_move(1)
        gv.gui.set_status_bar_msg(" ")
        if gv.show_moves == True:
            start, end =gv.gui.comment_view.get_buffer().get_bounds()
            gv.gui.comment_view.get_buffer().delete(start,end)
            gv.gui.comment_view.get_buffer().insert(start,"-")        



    #
    # called from gui.py when redo button click on toolbar (passed widget is
    # Gtk.ToolButton object) and when redo move is selected from menu
    # (or ctrl-r is pressed) (passed widget is Gtk.Action object)
    #
项目:impress-writer    作者:CSEC-NITH    | 项目源码 | 文件源码
def create_toolbar_top(self):
        toolbar=Gtk.Toolbar()
        self.grid.attach(toolbar,0,0,4,1)

##############New_Button#################################################

        button_new=Gtk.ToolButton()
        button_new.set_icon_name("document-new")
        toolbar.insert(button_new,0)
        toolbar.insert(Gtk.SeparatorToolItem(),1)

##############Open_Button############################################

        button_open=Gtk.ToolButton()
        button_open.set_icon_name("document-open")
        toolbar.insert(button_open,2)
        toolbar.insert(Gtk.SeparatorToolItem(),3)

#############Save_Buton#################################################

        button_save=Gtk.ToolButton()
        button_save.set_icon_name("document-save")
        toolbar.insert(button_save,4)
        toolbar.insert(Gtk.SeparatorToolItem(),5)

#########Help_Button#####################################################

        button_help=Gtk.ToolButton()
        button_help.set_icon_name("help-about")
        toolbar.insert(button_help,6)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_toolbutton(self, name, icon,
                          on_signal=None, callback=None, tooltip_text=None):
        toolbutton = Gtk.ToolButton(name)
        # FIXME: Tooltip text does not appear on the screen
        if not tooltip_text:
            toolbutton.set_tooltip_text(name)
        else:
            toolbutton.set_tooltip_text(tooltip_text)
        toolbutton.set_icon_widget(icon)

        if on_signal and callback:
            toolbutton.connect(on_signal, callback)
        return toolbutton
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _populate_toolbar(self, toolbar, *toolbuttons):
        """
        Populate a :class:`Gtk.Toolbar` with several :class:`Gtk.ToolButton`.

        .. note:: Tool buttons will be insert into ``toolbar`` following input
            arguments order.
        """
        for ind, toolbutton in enumerate(toolbuttons):
            toolbar.insert(toolbutton, ind)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _switch_widget_icons(self, widget, icon_id):
        """
        Switch icon type version ``regular`` to ``activated`` or the other way
        around depending on ``widget`` current icon.

        :param widget: :class:`Gtk.ToolButton`
        :param icon_id: icon name as :class:`str`
        """
        icon = self.images.switch_icon_version(icon_id, widget.get_icon_widget())
        widget.set_icon_widget(icon)
        widget.show_all()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def goto_move(self, move_idx):
        try:
            gv.ucib.stop_engine()
            gv.uciw.stop_engine()
        except:
            pass
        self.gameover = False
        if move_idx < len(self.movelist):
            while move_idx < len(self.movelist):
                self.undo_move()
        else:
            while move_idx > len(self.movelist):
                self.redo_move()

        self.stm = self.get_side_to_move()
        gv.gui.set_side_to_move(self.stm)

        gv.board.update()
        # gv.gui.set_status_bar_msg(" ")
        move = None
        try:
            move = self.movelist[len(self.movelist) - 1]
            self.lastmove = move
            # print "move ",move
        except IndexError:
            pass

        if move is not None:
            gv.gui.set_status_bar_msg(self.convert_move(move_idx)+move)
            if gv.show_moves == True:
               nmoves = len(self.movelist)
               path =(nmoves-1,)
               sel = gv.gui.move_view.get_selection()
               sel.select_path(path)  # path has to be set to nmoves-1 to hit the right selection
               self.move_list.set_move(nmoves)
               #print(nmoves, "goto move")             
        else:
            gv.gui.set_status_bar_msg(" ")

    #
    # called from gui.py when undo button click on toolbar (passed widget is
    # Gtk.ToolButton object) and when undo move is selected from menu
    # (or ctrl-u is pressed) (passed widget is Gtk.Action object)
    #