[gedit-list] Adding an item to the sidebar in a python extension



So, I am trying to write an extension for gedit in python. I want to use the sidebar, so that's the first thing I tried out. Code:

import gedit
import gtk

class ExamplePyPlugin(gedit.Plugin):
    def __init__(self):
        pass
    def activate(self,window):
        p=window.get_side_panel()
        print p
        img=gtk.Image()
        print img
        p.add_item(gtk.Button,'mybutton',img)
    def deactivate(self,window):
	pass

When I activate the plugin I get

<gedit.Panel object (GeditPanel) at 0xb5bdf144>
<gtk.Image object (GtkImage) at 0xb5bdf16c>
Traceback (most recent call last):
File "/home/chris/.gnome2/gedit/plugins/geditplugintest.py", line 12, in activate
    p.add_item(gtk.Button,img,img,img)
TypeError: the last arg should be either a gtk.Image or a stock_id string

So, if I read this right it is telling me that img is not a gtk.Image even though in the line before it is? Alternatively, this error is particularly misleading and something else is wrong (I realise that my image doesn't contain anything and that I probably can't just add a button like that - but if that's what it is complaining about shouldn't it say so?). Oh, I also tried a stock_id like it says - eg gtk.STOCK_OK that doesn't work either.

Any ideas? Thanks



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