I want to have names for menu actions from sqlite database for QGIS Plugin dynamically.
try:
os.chdir(newPath)
con = sqlite3.connect("db.sqlite")
cur=con.cursor()
cur.execute("""select queryLabel from custom_query;""")
cursor=cur.fetchall()
for row in cursor:
self.menu = QMenu( row[0], iface1.mainWindow().menuBar() )
self.menu.setObjectName( row[0] )
self.actionAttribute_Data=self.menu_WB_Query.addAction(row[0])
#self.actionAttribute_Data.triggered.connect(self.attribute_data)
except sqlite3.Error, e:
if con:
con.rollback()
print "Error %s:" % e.args[0]
#sys.exit(1)
finally:
if con:
con.close()
Putting this in initgui()
I achieved the desired output, but as initgui()
is called only once, the menu actions don't get refreshed if db is edited during execution of plugin.