-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why python function not work in custom function in QGIS 3.0? #27162
Comments
Author Name: dany Lefeuvre (dany Lefeuvre) oups error in tittle this is for qgis 3.2 |
Author Name: Jürgen Fischer (@jef-n)
import os, fnmatch @qgsfunction(args='auto', group='Custom') In QGIS 3.2 if I try in python mode, it works fine: import os, fnmatch def findphoto(nb, src1,src2): import os, fnmatch from PyQt5.QtCore import QFileInfo from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def findphoto(nb, src1,src2,feature, parent): lnb=0 val='NA' filen = QFileInfo(QgsProject.instance().fileName()) Dir_report=filen.absolutePath() for root, directories, filenames in os.walk(Dir_report): for filename in filenames: if fnmatch.fnmatch(filename, '*' +str(src1) + '*' + str(src2) + '*.jpg' ): lnb=lnb+1 if lnb==nb: val=os.path.join(root,filename) break return val In QGIS 2.18 it works fine (just change PyQt5 by PyQt4), in QGIS 3.2 it return "NA" value. In QGIS 3.2 if I try in python mode, it works fine: import os, fnmatch from PyQt5.QtCore import QFileInfo from qgis.core import * from qgis.gui import * def findphoto(nb, src1,src2): lnb=0 val='NA' filen = QFileInfo(QgsProject.instance().fileName()) Dir_report=filen.absolutePath() for root, directories, filenames in os.walk(Dir_report): for filename in filenames: if fnmatch.fnmatch(filename, '*' +str(src1) + '*' + str(src2) + '*.jpg' ): lnb=lnb+1 if lnb==nb: val=os.path.join(root,filename) break return val why? |
If this is a question, it should be asked in the mailing list. |
Author Name: dany Lefeuvre (dany Lefeuvre)
Original Redmine Issue: 19334
Affected QGIS version: 3.2
Redmine category:unknown
in QGIS atlas I use a custom function to find the first file containing texts :
In QGIS 2.18 it works fine (just change PyQt5 by PyQt4), in QGIS 3.2 it return "NA" value.
In QGIS 3.2 if I try in python mode, it works fine:
why?
The text was updated successfully, but these errors were encountered: