Re: Python plugin questions



On Σαβ, 2008-04-12 at 10:29 -0700, Steve Detwiler wrote:
> 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
> 

I used your code to make a plugin, which I didn't work for me either but
I do get an error on the terminal:

(eog:13456): EOG-CRITICAL **: eog_plugin_activate: assertion
`EOG_IS_PLUGIN (plugin)' failed

+1 for help!

btw can you send me the link to the console plugin you are using?

Here is the slightly modified code
import gtk
import eog

class ButtonPlugin(eog.Plugin):

	def test(self, b):
		print "hello from test"
		return False
		
	def add_button(self):
		ap = eog.Application()
		window = ap.get_windows()[0]
		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()
		




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