我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用gi.repository.Gtk.STOCK_ADD。
def get_icon_for_type(self, _type): theme = Gtk.IconTheme.get_default() try: if 'symbolic' in icon_names[_type.lower()]: print('Symbolic') return theme.load_icon(icon_names[_type.lower()], 16, 0) else: print('Not symbolic') path = os.path.abspath(__file__).replace('modules/autoComplete.py', '') path = os.path.join(path, 'resources/icons/' + icon_names[_type.lower()] + '.svg') print(path) a = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, 16, 16, True) print(type(a)) return a except: try: return theme.load_icon(Gtk.STOCK_ADD, 16, 0) except: return None
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
def __init__(self, configuration, channels): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_homogeneous(False) self.tool_bar = Gtk.Toolbar() self.pack_start(self.tool_bar, False, True, 0) tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON), "Add") tool.connect("clicked", self.on_add_clicked) self.tool_bar.insert(tool, -1) tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON), "Delete") tool.connect("clicked", self.on_delete_clicked) self.tool_bar.insert(tool, -1) self.content = Gtk.ListBox() self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.content) self.scrollTree.set_min_content_height(100) self.pack_start(self.scrollTree, True, True, 0) self.configuration = configuration self.channels = channels self.sbrick = None self.functionGroups = [] for group in configuration: fg = FunctionGroupBox(group, channels) # self.pack_start(fg, False, True, 0) self.content.add(fg) self.functionGroups.append(fg)
def setup_toolbar(self): self.g_toolbar = Gtk.Toolbar() self.g_actiongroup.add_actions([ ('Add', Gtk.STOCK_ADD, None, None, None, self.on_add_lesson_clicked), ('Remove', Gtk.STOCK_REMOVE, None, None, None, self.on_remove_lesson_clicked), ('Create', Gtk.STOCK_EXECUTE, _("Create Sheet"), None, None, self.on_create_sheet), ('Randomize', None, _("Randomize"), None, None, self.on_randomize), ]) self.g_ui_manager.insert_action_group(self.g_actiongroup, 0) uixml = """ <ui> <toolbar name='ExportToolbar'> <toolitem action='Add'/> <toolitem action='Remove'/> <toolitem action='New'/> <toolitem action='Open'/> <toolitem action='Save'/> <toolitem action='SaveAs'/> <toolitem action='Create'/> <toolitem action='Randomize'/> <toolitem action='Close'/> <toolitem action='Help'/> </toolbar> <accelerator action='Close'/> <accelerator action='New'/> <accelerator action='Open'/> <accelerator action='Save'/> </ui> """ self.g_ui_manager.add_ui_from_string(uixml) self.vbox.pack_start(self.g_ui_manager.get_widget("/ExportToolbar"), False, False, 0) self.g_ui_manager.get_widget("/ExportToolbar").set_style(Gtk.ToolbarStyle.BOTH)
def setup_toolbar(self): self.g_actiongroup.add_actions([ ('Export', Gtk.STOCK_EXECUTE, _("Export"), None, None, self.on_export), ('Add', Gtk.STOCK_ADD, None, None, None, self.on_add_lesson_clicked), ('Remove', Gtk.STOCK_REMOVE, None, None, None, self.on_remove_lesson_clicked), ]) self.g_ui_manager.insert_action_group(self.g_actiongroup, 0) uixml = """ <ui> <toolbar name='ExportToolbar'> <toolitem action='Add'/> <toolitem action='Remove'/> <toolitem action='New'/> <toolitem action='Open'/> <toolitem action='Save'/> <toolitem action='SaveAs'/> <toolitem action='Export'/> <toolitem action='Close'/> <toolitem action='Help'/> </toolbar> <accelerator action='Close'/> <accelerator action='New'/> <accelerator action='Open'/> <accelerator action='Save'/> </ui> """ self.g_ui_manager.add_ui_from_string(uixml) self.g_vbox.pack_start(self.g_ui_manager.get_widget("/ExportToolbar"), False, False, 0) self.g_ui_manager.get_widget("/ExportToolbar").set_style(Gtk.ToolbarStyle.BOTH)
def _build_add_button(self, label=None, on_signal="clicked", callback=None): """ Build an add button usable in side bar menu. This button triggers allow the creation of a new element in the menu. """ if not label: label = "Add" button = Gtk.Button(label, stock=Gtk.STOCK_ADD) button.set_margin_top(12) button.set_size_request(250, 20) if callback: button.connect(on_signal, callback) return button
def __init__(self, configuration): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_homogeneous(False) self.sequence_player = None self.tool_bar = Gtk.Toolbar() self.pack_start(self.tool_bar, False, True, 0) self.tool_add = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON), "Add") self.tool_add.connect("clicked", self.on_add_clicked) self.tool_bar.insert(self.tool_add, -1) self.tool_delete = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON), "Delete") self.tool_delete.connect("clicked", self.on_delete_clicked) self.tool_bar.insert(self.tool_delete, -1) self.tool_bar.insert(Gtk.SeparatorToolItem.new(), -1) self.tool_up = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.BUTTON), "Add") self.tool_up.connect("clicked", self.on_up_clicked) self.tool_bar.insert(self.tool_up, -1) self.tool_down = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.BUTTON), "Add") self.tool_down.connect("clicked", self.on_down_clicked) self.tool_bar.insert(self.tool_down, -1) self.tool_bar.insert(Gtk.SeparatorToolItem.new(), -1) self.tool_play = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON), "Run") self.tool_play.connect("clicked", self.on_run_clicked) self.tool_bar.insert(self.tool_play, -1) self.enable_tools(True, False) self.content = Gtk.ListBox() self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.content) self.scrollTree.set_min_content_height(100) self.pack_start(self.scrollTree, True, True, 0) self.sbrickConfiguration = configuration self.sbrick = None self.sequenceSteps = [] if "sequence" in self.sbrickConfiguration: for step in self.sbrickConfiguration["sequence"]: stepbox = SequenceStepBox(step, self.sbrickConfiguration["functions"]) self.content.add(stepbox) self.sequenceSteps.append(stepbox) else: self.sbrickConfiguration["sequence"] = []