Hi Seggie, Just one line of code to add a folder to browser panel:
iface.browserModel().addFavoriteDirectory('/home/jgr/tmp') Regards, Jorge On 22/05/20 14:37, Seggie, Graeme wrote: > > 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 > > > > > _______________________________________________ > Qgis-user mailing list > Qgis-user@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user -- Email Signature Logo <https://www.geomaster.pt> *Geomaster* *Jorge Gustavo Rocha* | Software Engineer *e:*j...@geomaster.pt | *m:*+351 910 333 888 *g:*41.54094,-8.40490 | *v: *510 906 109 *a: * Rua António Cândido Pinto, 67, 4715-400 Braga
_______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user