3

I would like to script QGIS to import a style library as part as a configuration for a new user. By Python commands, how do I instruct QGIS to do what a QGIS user can do with the "Import Items" dialog box that is within the "Style Manager". Specifically, I would like to instruct QGIS to: Import from "File" (not "URL"); check to "Add to favorites"; blank for "Additional tag(s) and "Select All".

When I look at the QGIS Python API I have found classes for working map layers or for prompting the Style Manager Dialog. From my understanding the map layers requires a layer to exist and isn't suitable for a blank workspace, whilst, the Dialog option doesn't allow one to set all of the options.

"Import Item(s)" dialog box from QGIS Style Manager

Some pseudo code could be like:

newStyleCollection = QgsStyleManager()
newStyleCollection = newStyleCollection.importXML('c:\\SymbolSet.xml')
newStyleCollection.AddToFavourites('True')
newStyleCollection.AdditionalTags(None)
newStyleCollection.sync()

I am basically after the libraries for working with the QGIS style manager.

  • Don't have a piece of code or pseudocode ? – Fran Raga May 9 '19 at 8:31
  • I have added some pseudo code – Philip Whitten May 9 '19 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.