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


Python Gtk.STOCK_ADD属性代码示例

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


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

示例1: _button_box

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def _button_box(self):
		'''
		Panel which includes buttons for manipulating the current treeview:
		- add / delete
		- move up / move down row
		:return: vbox-panel
		'''
		vbox = Gtk.VBox(spacing=5)
		for stock, handler, data, tooltip in (
			(Gtk.STOCK_ADD, self.on_add_new_column, None, _('Add column')),  # T: hoover tooltip
			(Gtk.STOCK_DELETE, self.on_delete_column, None, _('Remove column')),  # T: hoover tooltip
			(Gtk.STOCK_GO_UP, self.on_move_column, -1, _('Move column ahead')),  # T: hoover tooltip
			(Gtk.STOCK_GO_DOWN, self.on_move_column, 1, _('Move column backward')),  # T: hoover tooltip
		):
			button = IconButton(stock)
			if data:
				button.connect('clicked', handler, data)
			else:
				button.connect('clicked', handler)
			button.set_tooltip_text(tooltip)
			vbox.pack_start(button, False, True, 0)

		vbox.show_all()
		return vbox 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:26,代码来源:tableeditor.py

示例2: get_view

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def get_view(self):
        """It's called from Preference. It creates the view and returns it"""
        vbox = Gtk.VBox(False, 3)
        # create columns
        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', False)
        column = Gtk.TreeViewColumn(_('Sensor'), renderer, text=0)
        self._tree_view.append_column(column)

        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', False)
        column = Gtk.TreeViewColumn(_('Description'), renderer, text=1)
        self._tree_view.append_column(column)

        self._tree_view.expand_all()
        sw = Gtk.ScrolledWindow()
        sw.add_with_viewport(self._tree_view)
        vbox.pack_start(sw, True, True, 0)

        # add buttons
        hbox = Gtk.HBox()
        new_button = Gtk.Button.new_from_stock(Gtk.STOCK_NEW)
        new_button.connect('clicked', self._on_edit_sensor)
        hbox.pack_start(new_button, False, False, 0)

        edit_button = Gtk.Button.new_from_stock(Gtk.STOCK_EDIT)
        edit_button.connect('clicked', self._on_edit_sensor, False)
        hbox.pack_start(edit_button, False, False, 1)

        del_button = Gtk.Button.new_from_stock(Gtk.STOCK_DELETE)
        del_button.connect('clicked', self._on_del_sensor)
        hbox.pack_start(del_button, False, False, 2)

        add_button = Gtk.Button.new_from_stock(Gtk.STOCK_ADD)
        add_button.connect('clicked', self._on_add_sensor)
        hbox.pack_end(add_button, False, False, 3)
        vbox.pack_end(hbox, False, False, 1)

        frame = Gtk.Frame.new(_('Sensors'))
        frame.add(vbox)
        return frame 
开发者ID:fossfreedom,项目名称:indicator-sysmonitor,代码行数:43,代码来源:preferences.py

示例3: get_icon_for_type

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def get_icon_for_type(self, _type):
        theme = Gtk.IconTheme.get_default()
        try:
            return theme.load_icon(icon_names[_type.lower()], 16, 0)
        except:
            try:
                return theme.load_icon(Gtk.STOCK_ADD, 16, 0)
            except:
                return None 
开发者ID:isamert,项目名称:gedi,代码行数:11,代码来源:gedi.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def __init__(self, parent):
		Dialog.__init__(self, parent, _('Custom Tools'), buttons=Gtk.ButtonsType.CLOSE) # T: Dialog title
		self.set_help(':Help:Custom Tools')
		self.manager = CustomToolManager()

		self.add_help_text(_(
			'You can configure custom tools that will appear\n'
			'in the tool menu and in the tool bar or context menus.'
		)) # T: help text in "Custom Tools" dialog

		hbox = Gtk.HBox(spacing=5)
		self.vbox.pack_start(hbox, True, True, 0)

		self.listview = CustomToolList(self.manager)
		hbox.pack_start(self.listview, True, True, 0)

		vbox = Gtk.VBox(spacing=5)
		hbox.pack_start(vbox, False, True, 0)

		for stock, handler, data in (
			(Gtk.STOCK_ADD, self.__class__.on_add, None),
			(Gtk.STOCK_EDIT, self.__class__.on_edit, None),
			(Gtk.STOCK_DELETE, self.__class__.on_delete, None),
			(Gtk.STOCK_GO_UP, self.__class__.on_move, -1),
			(Gtk.STOCK_GO_DOWN, self.__class__.on_move, 1),
		):
			button = IconButton(stock) # TODO tooltips for icon button
			if data:
				button.connect_object('clicked', handler, self, data)
			else:
				button.connect_object('clicked', handler, self)
			vbox.pack_start(button, False, True, 0) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:34,代码来源:customtools.py

示例5: create_toolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [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

示例6: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [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

示例7: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def __init__(self, notebook, navigation, uistate, get_page_func):
		GObject.GObject.__init__(self)

		self.notebook = notebook
		self.navigation = navigation
		self.uistate = uistate
		self.save_flag = False # if True save bookmarks in config
		self.add_bookmarks_to_beginning = False # add new bookmarks to the end of the bar
		self.max_bookmarks = False # maximum number of bookmarks
		self._get_page = get_page_func # function to get current page

		# Create button to add new bookmarks.
		self.plus_button = IconsButton(Gtk.STOCK_ADD, Gtk.STOCK_REMOVE, relief = False)
		self.plus_button.set_tooltip_text(_('Add bookmark/Show settings')) # T: button label
		self.plus_button.connect('clicked', lambda o: self.add_new_page())
		self.plus_button.connect('button-release-event', self.do_plus_button_popup_menu)
		self.pack_start(self.plus_button, False, False, 0)

		# Create widget for bookmarks.
		self.scrolledbox = ScrolledHBox()
		self.pack_start(self.scrolledbox, True, True, 0)

		# Toggle between full/short page names.
		self.uistate.setdefault('show_full_page_name', False)

		# Save path to use later in Copy/Paste menu.
		self._saved_bookmark = None

		self.paths = [] # list of bookmarks as string objects
		self.uistate.setdefault('bookmarks', [])

		# Add pages from config to the bar.
		for path in self.uistate['bookmarks']:
			page = self.notebook.get_page(Path(path))
			if page.exists() and (page.name not in self.paths):
				self.paths.append(page.name)

		self.paths_names = {} # dict of changed names of bookmarks
		self.uistate.setdefault('bookmarks_names', {})
		# Function to transform random string to paths_names format.
		self._convert_path_name = lambda a: ' '.join(a[:25].split())

		# Add alternative bookmark names from config.
		for path, name in self.uistate['bookmarks_names'].items():
			if path in self.paths:
				try:
					name = self._convert_path_name(name)
					self.paths_names[path] = name
				except:
					logger.error('BookmarksBar: Error while loading path_names.')

		# Delete a bookmark if a page is deleted.
		self.connectto(self.notebook, 'deleted-page',
					   lambda obj, path: self.delete(path.name)) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:56,代码来源:bookmarksbar.py

示例8: on_button_press_event

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_ADD [as 别名]
def on_button_press_event(self, treeview, event):
		'''
		Displays a context-menu on right button click
		Opens the link of a tablecell on CTRL pressed and left button click
		'''
		if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 1 and event.get_state() & Gdk.ModifierType.CONTROL_MASK:
			# With CTRL + LEFT-Mouse-Click link of cell is opened
			cellvalue = self.fetch_cell_by_event(event, treeview)
			linkvalue = self.get_linkurl(cellvalue)
			if linkvalue:
				self.emit('link-clicked', {'href': str(linkvalue)})
			return

		if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
			# Right button opens context menu
			self._keep_toolbar_open = True
			cellvalue = self.fetch_cell_by_event(event, treeview)
			linkvalue = self.get_linkurl(cellvalue)
			linkitem_is_activated = (linkvalue is not None)

			menu = Gtk.Menu()

			for stock, handler, data, tooltip in (
				(Gtk.STOCK_ADD, self.on_add_row, None, _('Add row')),  # T: menu item
				(Gtk.STOCK_DELETE, self.on_delete_row, None, _('Delete row')),  # T: menu item
				(Gtk.STOCK_COPY, self.on_clone_row, None, _('Clone row')),  # T: menu item
				(None, None, None, None),  # T: menu item
				(Gtk.STOCK_JUMP_TO, self.on_open_link, linkvalue, _('Open cell content link')),  # T: menu item
				(None, None, None, None),
				(Gtk.STOCK_GO_UP, self.on_move_row, -1, _('Row up')),  # T: menu item
				(Gtk.STOCK_GO_DOWN, self.on_move_row, 1, _('Row down')),  # T: menu item
				(None, None, None, None),
				(Gtk.STOCK_PREFERENCES, self.on_change_columns, None, _('Change columns'))  # T: menu item
			):

				if stock is None:
					menu.append(Gtk.SeparatorMenuItem())
				else:
					item = Gtk.ImageMenuItem(stock)
					item.set_always_show_image(True)
					item.set_label(_(tooltip))
					if data:
						item.connect_after('activate', handler, data)
					else:
						item.connect_after('activate', handler)
					if handler == self.on_open_link:
						item.set_sensitive(linkitem_is_activated)
					menu.append(item)

			menu.show_all()
			gtk_popup_at_pointer(menu, event) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:53,代码来源:tableeditor.py


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