[Qgis-user] Adding folder location to Browser - Favorites with Python

Seggie, Graeme Graeme.Seggie at sepa.org.uk
Fri May 22 06:37:43 PDT 2020


Hello,

I am struggling to get something to work, which would seem to be an easy thing to do, but cannot quite make my understanding of the python docs work in practice.

What I would like to do, is run some python to add some folders to the favorites area in the browser within QGIS. This is to get round an environemental constraint of not being able to save a profile i.e. quickly add a python script to setup the favorites each time log on.

This is what I have tried thus far:

url = "U:\Tyres"
qgis.gui.QgsBrowserDockWidget(addFavoriteDirectory, uri)

-->

Traceback (most recent call last):
  File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 3, in <module>
NameError: name 'addFavoriteDirectory' is not defined

AND

url = "U:\Tyres"
qgis.gui.QgsBrowserDockWidget(addFavorite, uri)

-->

Traceback (most recent call last):
  File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 3, in <module>
NameError: name 'addFavorite' is not defined

Should I be calling the addFavorite code differently? This is within the Python console and script area of same.

Regards,
Graeme

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200522/f2c17f00/attachment.html>


More information about the Qgis-user mailing list