Python plugin questions



I am having some difficulty getting my sample plugin working. I'm probably making an obvious mistake, but I can't seem to find it. I am trying to add a button to the eog toolbar that calls a function when clicked. When I run my code and then query for the UI xml from the window's ui manager, I see my new toolitem in the XML, but it never appears in the toolbar itself. Any help would be appreciated. I am using the python console plugin to run the code below.

Thanks,

Steve


import gtk

class MyToolbarItems:

    def test(self, b):
        print "Hello from test"
        return False

    def add_button(self):
        self.uimanager = window.get_ui_manager()
self.newUi = '<ui><toolbar name="Toolbar"><toolitem action="Test"/></toolbar></ui>'
        self.mergeId = self.uimanager.add_ui_from_string(self.newUi)

        print self.mergeId

        self.actionGroup = gtk.ActionGroup("TestGroup")
        self.actionGroup.add_actions([('Test', None, '_Test', None,
                                       'Test this', self.test)])
        self.uimanager.insert_action_group(self.actionGroup, 1)


self.actionGroup.get_action('Test').set_property('short-label', '_Test')
        self.actionGroup.get_action('Test').set_property('visible', True)

        self.uimanager.ensure_update()


    def __init__(self):
        self.add_button()


foo = MyToolbarItems()
print foo.uimanager.get_ui()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]