当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.ToolButton方法代码示例

本文整理汇总了Python中gi.repository.Gtk.ToolButton方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.ToolButton方法的具体用法?Python Gtk.ToolButton怎么用?Python Gtk.ToolButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.ToolButton方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_toolitem

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def add_toolitem(self, name, group, position, image_file, description,
                     toggle):
        if toggle:
            tbutton = Gtk.ToggleToolButton()
        else:
            tbutton = Gtk.ToolButton()
        tbutton.set_label(name)

        if image_file is not None:
            image = Gtk.Image()
            image.set_from_file(image_file)
            tbutton.set_icon_widget(image)

        if position is None:
            position = -1

        self._add_button(tbutton, group, position)
        signal = tbutton.connect('clicked', self._call_tool, name)
        tbutton.set_tooltip_text(description)
        tbutton.show_all()
        self._toolitems.setdefault(name, [])
        self._toolitems[name].append((tbutton, signal)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:24,代码来源:backend_gtk3.py

示例2: addButtonToToolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def addButtonToToolbar(self, plugin_api):
        if not self.checkTomboyPresent():
            return
        tb_Taskbutton_image = Gtk.Image()
        tb_Taskbutton_image_path = self.tomboy_icon_path
        tb_Taskbutton_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
            tb_Taskbutton_image_path, 16, 16)
        tb_Taskbutton_image.set_from_pixbuf(tb_Taskbutton_pixbuf)
        self.tb_Taskbutton = Gtk.ToolButton(tb_Taskbutton_image)
        self.tb_Taskbutton.set_label(_("Add Tomboy note"))
        self.tb_Taskbutton.connect('clicked', self.onTbTaskButton,
                                   self.plugin_api)
        self.tb_Taskbutton.show_all()
        self.plugin_api.add_toolbar_item(self.tb_Taskbutton)

    # Converts all the textual tokens in tomboy note widgets 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:18,代码来源:tomboy.py

示例3: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def __init__(self, title):
        View.__init__(self)

        toolbar = Gtk.Toolbar()
        toolbar.props.show_arrow = False
        fullscreen_icon = label.create_button_label(constants.BUTTON_EXP)
        self['maximize_button'] = Gtk.ToolButton()
        self['maximize_button'].set_icon_widget(fullscreen_icon)
        redock_icon = label.create_button_label(constants.BUTTON_UNDOCK)
        self['redock_button'] = Gtk.ToolButton()
        self['redock_button'].set_icon_widget(redock_icon)
        self['redock_button'].set_tooltip_text("Redock")
        toolbar.insert(self['maximize_button'], 0)
        toolbar.insert(self['redock_button'], 1)

        self['headerbar'].props.title = title
        self['headerbar'].pack_end(toolbar)
        self['headerbar'].show_all()

        self.get_top_widget().set_titlebar(self['headerbar']) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:22,代码来源:undocked_window.py

示例4: _init_toolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def _init_toolbar(self):
        self.set_style(Gtk.ToolbarStyle.ICONS)
        basedir = os.path.join(rcParams['datapath'],'images')

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.insert( Gtk.SeparatorToolItem(), -1 )
                continue
            fname = os.path.join(basedir, image_file + '.png')
            image = Gtk.Image()
            image.set_from_file(fname)
            tbutton = Gtk.ToolButton()
            tbutton.set_label(text)
            tbutton.set_icon_widget(image)
            self.insert(tbutton, -1)
            tbutton.connect('clicked', getattr(self, callback))
            tbutton.set_tooltip_text(tooltip_text)

        toolitem = Gtk.SeparatorToolItem()
        self.insert(toolitem, -1)
        toolitem.set_draw(False)
        toolitem.set_expand(True)

        toolitem = Gtk.ToolItem()
        self.insert(toolitem, -1)
        self.message = Gtk.Label()
        toolitem.add(self.message)

        self.show_all() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:backend_gtk3.py

示例5: _init_toolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def _init_toolbar(self):
        self.set_style(Gtk.ToolbarStyle.ICONS)
        basedir = os.path.join(rcParams['datapath'], 'images')

        self._gtk_ids = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.insert(Gtk.SeparatorToolItem(), -1)
                continue
            fname = os.path.join(basedir, image_file + '.png')
            image = Gtk.Image()
            image.set_from_file(fname)
            self._gtk_ids[text] = tbutton = Gtk.ToolButton()
            tbutton.set_label(text)
            tbutton.set_icon_widget(image)
            self.insert(tbutton, -1)
            tbutton.connect('clicked', getattr(self, callback))
            tbutton.set_tooltip_text(tooltip_text)

        toolitem = Gtk.SeparatorToolItem()
        self.insert(toolitem, -1)
        toolitem.set_draw(False)
        toolitem.set_expand(True)

        toolitem = Gtk.ToolItem()
        self.insert(toolitem, -1)
        self.message = Gtk.Label()
        toolitem.add(self.message)

        self.show_all() 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:32,代码来源:backend_gtk3.py

示例6: onTaskOpened

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def onTaskOpened(self, plugin_api):
        image_geolocalization_path = os.path.join(self.plugin_path,
                                                  "icons/hicolor/24x24/\
                                                  geolocalization.png")
        pixbuf_geolocalization = GdkPixbuf.Pixbuf.new_from_file_at_size(
            image_geolocalization_path, 24, 24)

        # create the image and associate the pixbuf
        icon_geolocalization = Gtk.Image()
        icon_geolocalization.set_from_pixbuf(pixbuf_geolocalization)
        icon_geolocalization.show()

        # toolbar button for the location_view
        btn_location_view = Gtk.ToggleToolButton()
        btn_location_view.set_icon_widget(icon_geolocalization)
        btn_location_view.set_label("Location View")

        self.task_separator = plugin_api.add_task_toolbar_item(
            Gtk.SeparatorToolItem())

        btn_set_location = Gtk.ToolButton()
        btn_set_location.set_icon_widget(icon_geolocalization)
        btn_set_location.set_label("Set/View location")
        btn_set_location.connect('clicked', self.set_task_location, plugin_api)
        self.btn_set_location = plugin_api.add_task_toolbar_item(
            btn_set_location) 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:28,代码来源:geolocalized_tasks.py

示例7: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def __init__(self):
        # task editor widget
        self.vbox = None
        self.button = Gtk.ToolButton()
        self.other_stop_button = self.button

        self.tree = None
        self.liblarch_callbacks = []
        self.tracked_task_id = None 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:11,代码来源:hamster.py

示例8: create_toolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def create_toolbar(self):
		'''This function creates a toolbar which is displayed next to the table'''
		toolbar = Gtk.Toolbar()
		toolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
		toolbar.set_style(Gtk.ToolbarStyle.ICONS)
		toolbar.set_border_width(1)

		for pos, stock, handler, data, tooltip in (
			(0, Gtk.STOCK_ADD, self.on_add_row, None, _('Add row')),  # T: tooltip on mouse hover
			(1, Gtk.STOCK_DELETE, self.on_delete_row, None, _('Remove row')),  # T: tooltip on mouse hover
			(2, Gtk.STOCK_COPY, self.on_clone_row, None, _('Clone row')),  # T: tooltip on mouse hover
			(3, None, None, None, None),
			(4, Gtk.STOCK_GO_UP, self.on_move_row, -1, _('Row up')),  # T: tooltip on mouse hover
			(5, Gtk.STOCK_GO_DOWN, self.on_move_row, 1, _('Row down')),  # T: tooltip on mouse hover
			(6, None, None, None, None),
			(7, Gtk.STOCK_PREFERENCES, self.on_change_columns, None, _('Change columns')),  # T: tooltip on mouse hover
			(8, None, None, None, None),
			(9, Gtk.STOCK_HELP, self.on_open_help, None, _('Open help')),  # T: tooltip on mouse hover
		):
			if stock is None:
				toolbar.insert(Gtk.SeparatorToolItem(), pos)
			else:
				button = Gtk.ToolButton(stock)
				if data:
					button.connect('clicked', handler, data)
				else:
					button.connect('clicked', handler)
				button.set_tooltip_text(tooltip)
				toolbar.insert(button, pos)

		toolbar.set_size_request(300, -1)
		toolbar.set_icon_size(Gtk.IconSize.MENU)

		return toolbar 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:36,代码来源:tableeditor.py

示例9: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def __init__(self, stock_id, menu):
        Gtk.ToolButton.__init__(self)
        self.set_stock_id(stock_id)
        self._menu = menu
        self.connect("clicked", self._on_clicked)
        self.show_all() 
开发者ID:jendrikseipp,项目名称:rednotebook,代码行数:8,代码来源:customwidgets.py

示例10: _create_toolitems

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def _create_toolitems(self):
        iconSize = Gtk.IconSize.SMALL_TOOLBAR

        for text, tooltip_text, image_num, callback, callback_arg, scroll \
                in self.toolitems:
            if text is None:
                self.insert( Gtk.SeparatorToolItem(), -1 )
                continue
            image = Gtk.Image()
            image.set_from_stock(image_num, iconSize)
            tbutton = Gtk.ToolButton()
            tbutton.set_label(text)
            tbutton.set_icon_widget(image)
            self.insert(tbutton, -1)
            if callback_arg:
                tbutton.connect('clicked', getattr(self, callback),
                                callback_arg)
            else:
                tbutton.connect('clicked', getattr(self, callback))
            if scroll:
                tbutton.connect('scroll_event', getattr(self, callback))
            tbutton.set_tooltip_text(tooltip_text)

        # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
        self.axes_toolitem = Gtk.ToolItem()
        self.insert(self.axes_toolitem, 0)
        self.axes_toolitem.set_tooltip_text(
                            'Select axes that controls affect')

        align = Gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
        self.axes_toolitem.add(align)

        self.menubutton = Gtk.Button ("Axes")
        align.add (self.menubutton)

        def position_menu (menu):
            """Function for positioning a popup menu.
            Place menu below the menu button, but ensure it does not go off
            the bottom of the screen.
            The default is to popup menu at current mouse position
            """
            x0, y0    = self.window.get_origin()
            x1, y1, m = self.window.get_pointer()
            x2, y2    = self.menubutton.get_pointer()
            sc_h      = self.get_screen().get_height()
            w, h      = menu.size_request()

            x = x0 + x1 - x2
            y = y0 + y1 - y2 + self.menubutton.allocation.height
            y = min(y, sc_h - h)
            return x, y, True

        def button_clicked (button, data=None):
            self.axismenu.popup (None, None, position_menu, 0,
                                 Gtk.get_current_event_time())

        self.menubutton.connect ("clicked", button_clicked) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:59,代码来源:backend_gtk3.py

示例11: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def __init__(self, persp):
        self.persp = persp
        self.filtered = False

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        # buttons
        toolbar = Gtk.Toolbar()

        firstButton = Gtk.ToolButton(stock_id=Gtk.STOCK_MEDIA_PREVIOUS)
        toolbar.insert(firstButton, -1)

        prevButton = Gtk.ToolButton(stock_id=Gtk.STOCK_MEDIA_REWIND)
        toolbar.insert(prevButton, -1)

        nextButton = Gtk.ToolButton(stock_id=Gtk.STOCK_MEDIA_FORWARD)
        toolbar.insert(nextButton, -1)

        lastButton = Gtk.ToolButton(stock_id=Gtk.STOCK_MEDIA_NEXT)
        toolbar.insert(lastButton, -1)

        self.filterButton = Gtk.ToggleToolButton(Gtk.STOCK_FIND)
        self.filterButton.set_tooltip_text(_("Filter game list by current game moves"))
        toolbar.insert(self.filterButton, -1)

        addButton = Gtk.ToolButton(stock_id=Gtk.STOCK_ADD)
        addButton.set_tooltip_text(_("Add sub-fen filter from position/circles"))
        toolbar.insert(addButton, -1)

        firstButton.connect("clicked", self.on_first_clicked)
        prevButton.connect("clicked", self.on_prev_clicked)
        nextButton.connect("clicked", self.on_next_clicked)
        lastButton.connect("clicked", self.on_last_clicked)

        addButton.connect("clicked", self.on_add_clicked)
        self.filterButton.connect("clicked", self.on_filter_clicked)

        tool_box = Gtk.Box()
        tool_box.pack_start(toolbar, False, False, 0)

        # board
        self.gamemodel = self.persp.gamelist.gamemodel
        self.boardcontrol = BoardControl(self.gamemodel, {}, game_preview=True)
        self.boardview = self.boardcontrol.view
        self.board = self.gamemodel.boards[self.boardview.shown].board
        self.boardview.set_size_request(170, 170)

        self.boardview.got_started = True
        self.boardview.auto_update_shown = False

        self.box.pack_start(self.boardcontrol, True, True, 0)
        self.box.pack_start(tool_box, False, True, 0)
        self.box.show_all()

        selection = self.persp.gamelist.get_selection()
        self.conid = selection.connect_after('changed', self.on_selection_changed)
        self.persp.gamelist.preview_cid = self.conid

        # force first game to show
        self.persp.gamelist.set_cursor(0) 
开发者ID:pychess,项目名称:pychess,代码行数:62,代码来源:PreviewPanel.py

示例12: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ToolButton [as 别名]
def __init__(self, url):
        from pychess.System.uistuff import keepWindowSize
        self.window = Gtk.Window()
        keepWindowSize("webkitbrowser", self.window, (800, 600))

        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.window.add(self.vbox)

        self.box = Gtk.Box()

        self.toolbar = Gtk.Toolbar()
        self.box.pack_start(self.toolbar, False, False, 0)

        self.go_back_button = Gtk.ToolButton(stock_id=Gtk.STOCK_GO_BACK)
        self.toolbar.insert(self.go_back_button, -1)

        self.go_forward_button = Gtk.ToolButton(stock_id=Gtk.STOCK_GO_FORWARD)
        self.toolbar.insert(self.go_forward_button, -1)

        self.go_refresh_button = Gtk.ToolButton(stock_id=Gtk.STOCK_REFRESH)
        self.toolbar.insert(self.go_refresh_button, -1)

        self.url = Gtk.Entry()
        self.box.pack_start(self.url, True, True, 0)

        self.search_entry = Gtk.SearchEntry()
        self.box.pack_start(self.search_entry, False, False, 0)

        self.vbox.pack_start(self.box, False, False, 0)

        self.view = WebKit.WebView()
        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.add(self.view)

        self.vbox.pack_start(self.scrolled_window, True, True, 0)

        self.window.show_all()

        self.view.connect("load-committed", self.check_buttons)
        self.view.connect("title-changed", self.change_title)

        self.url.connect("activate", self.go)
        self.search_entry.connect("activate", self.search)
        self.go_back_button.connect("clicked", self.go_back)
        self.go_forward_button.connect("clicked", self.go_forward)
        self.go_refresh_button.connect("clicked", self.refresh)

        self.view.open(url)
        self.view.show() 
开发者ID:pychess,项目名称:pychess,代码行数:51,代码来源:WebKitBrowser.py


注:本文中的gi.repository.Gtk.ToolButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。