Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am writing a python plugin for QGIS 1.7 (started it on QGIS 1.6 but switched to 1.7 recently). Since I switched to 1.7 my unload function doesn't seem to be working anymore. Whenever I implemented changes to the code I use the "Plugin Reloader" plugin to load the newest version of my code.

In the MenuBar this causes an additional, new instanec of the plugin to load while it doesn't unload the old ones. After doing this a couple of time I end up having a list of endless outdated outdated references to my plugin. For the menu bar icon the same does NOT happen...

The code worked fine in 1.6 and I seem to be correctly following all the online examples. It shouldn't be a problem, that I'm creating two actions, at least the PluginReloader plugin seems to do the same.

def initGui(self): 
    [...]
    # GemEB Tool
    self.action_tool = QAction(QIcon(iconpath), u"GemEBTool", self.iface.mainWindow())
    self.action_tool.setWhatsThis(u"GemEBTool")
    self.iface.addPluginToMenu("&GemeindeEnergieBeratung 1.5", self.action_tool)
    self.iface.addToolBarIcon(self.action_tool)
    QObject.connect(self.action_tool, SIGNAL("triggered()"), self.run_tool)

    # Solarrechner
    self.action_solarrechner = QAction(QIcon(iconpath), u"GemEB Solarrechner", self.iface.mainWindow())
    self.action_solarrechner.setWhatsThis(u"GemEB Solarrechner")
    self.iface.addToolBarIcon(self.action_solarrechner)
    self.iface.addPluginToMenu("&GemeindeEnergieBeratung 1.5", self.action_solarrechner)
    QObject.connect(self.action_solarrechner, SIGNAL("triggered()"), self.run_solarrechner)

def unload(self):
    # GemEB Tool
    self.iface.removePluginMenu("&GemEBTool",self.action_tool)        
    self.iface.removeToolBarIcon(self.action_tool)

    # Solarrechner
    self.iface.removePluginMenu("&GemEB Solarrechner",self.action_solarrechner)        
    self.iface.removeToolBarIcon(self.action_solarrechner)
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

While the menu entry is added with

self.iface.addPluginToMenu("&GemeindeEnergieBeratung 1.5", self.action_tool)

you try to remove it with

self.iface.removePluginMenu("&GemEBTool",self.action_tool) 

My theory would be that it doesn't work because "&GemeindeEnergieBeratung 1.5" != "&GemEBTool"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.