开发者

Custom Icon in gtk toggle_action

I have the following code which adds a toolbar icon "gtk-info" (from stock) to a python Gtk开发者_JAVA百科+ window. I would like to have a custom icon instead. How would I do that?

    self.action = ('ActivateSqueezeboxMode','gtk-info', _('SqueezeboxTools'),
                    None, _('Activate Squeezebox mode'),
                    self.activate_button_press, True)
    self.action_group = gtk.ActionGroup('SqueezeboxPluginActions')
    self.action_group.add_toggle_actions([self.action])
    uim = self.shell.get_ui_manager()
    uim.insert_action_group (self.action_group, 0)
    self.ui_id = uim.add_ui_from_string(context_ui)
    uim.ensure_update()


Try this:

self.action = ('ActivateSqueezeboxMode', None, _('SqueezeboxTools'),
                None, _('Activate Squeezebox mode'),
                self.activate_button_press, True)
self.action_group = gtk.ActionGroup('SqueezeboxPluginActions')
self.action_group.add_toggle_actions([self.action])
# now get your action back out of the action group so you can modify it
action = self.action_group.get_action('ActivateSqueezeboxMode')
action.set_icon_name('my-custom-icon')

to use a named icon, or

action.set_gicon(my_custom_gicon)

as the last line to use a gio.Icon (see for example gio.FileIcon.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜