1

I am trying to set QGIS 2.8.1 (Linux Mint 17.2) to add the filename/path to layouts.

I am using this post as a guide How to add the current project path in Print Composer? However, I haven't got startup.py - I ran searchmonkey on my entire hard disk. The PyQGIS cookbook says "...if it's exists" but no reference to how to create it.

I tried creating a file of that name & pasting the code into it but QGIS wouldn't start, with Python-related complaints. I'm assuming the file should have a header & instructions, like an HTML document does? I can't seem to find this. I've looked in the QGIS settings to try & find it, with no success. BTW, I'm completely new to Python.

closed as off-topic by underdark Apr 5 '16 at 16:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – underdark
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You might need to add the contents of what you put into your startup.py file. This file is just a Python script, so it may not need a 'header' or instructions like an HTML document. Your Python-related complaints would also help. – Richard Morgan Apr 5 '16 at 13:40
  • I paste this into a newly-created startup.py placed in /home/jonathan/.qgis2/python: from qgis.core import QgsProject @qgsfunction(0, "Python") def projectpath(values, feature, parent): return QgsProject.instance.fileName() – user3418765 Apr 5 '16 at 14:30
  • Couldn't load qgis.user. Python support will be disabled. Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/usr/lib/python2.7/dist-packages/qgis/user.py", line 30, in execfile(startuppy, locals(), globals()) File "/home/jonathan/.qgis2//python/startup.py", line 3, in @qgsfunction(0, "Python") NameError: name 'qgsfunction' is not defined Python version: 2.7.6 (default, Jun 22 2015, 18:01:27) [GCC 4.8.2] – user3418765 Apr 5 '16 at 14:30
  • its not finding the qgsfunction decorator. try adding from qgis.utils import qgsfunction (see this blog post by NathanW) – Steven Kay Apr 5 '16 at 14:55
  • Starts up OK now. Just need to digest that post of Nathan's - I had looked at it, but somewhat blankly. Need to get my head round Python a bit. – user3418765 Apr 5 '16 at 15:24

Browse other questions tagged or ask your own question.