I'm using a custom feature form for QGIS 2.18 (custom .ui file + custom Form.py file containing the Python init function used by the form). I would like to be able to put the .ui file and the Form.py file anywhere I want because the final form will be used by several people and thus should be located in a shared folder, not a user-specific folder. I have been able to do that easily for the .ui, but QGIS is unable to find the Form.py unless I put it in QGIS 2.18 bin folder.

How can I tell QGIS to look for the Form.py in another folder than bin? Here's an abstract from the corresponding XML file:

<editform>C://My_path/mycustom.ui</editform> *<!--This works fine-->*
<editforminitfilepath>C://My_path/mycustomForm.py</editforminitfilepath> *<!--This does not seem to work: QGIS keeps ignoring the path I provide here-->*

I found a solution - don't know if it's the best one, but it's fine by me. I added a startup.py file in the .qgis2/python folder. This file must contain the following lines:

import sys

I think you can add as many folders as you want - just add more "sys.path.append" lines in your file if you want to add more than one folder.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.