[Qgis-developer] Designing a plugin : TypeError raised on MacOS machines but not on Windows
Junior Delaz
delazj at gmail.com
Wed Apr 15 09:20:49 PDT 2015
Hi all,
I'm testing a plugin I created with Plugin Builder on different platforms
and encounter a problem I can't understand. The same piece of code works on
Windows machines but not on MacOS ones where I get this error message.
Traceback (most recent call last):
File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
369, in saveFile
progress.setLabelText(self.tr( u'Exporting maps from {}…'.format(title)
))
File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
87, in tr
return QCoreApplication.translate('MapsPrinter', message)
TypeError: function takes exactly 5 arguments (1 given)
QCoreApplication.translate is called in a tr function that is generated by
Plugin Builder :
def tr(self, message):
"""Get the translation for a string using Qt translation API.
We implement this ourselves since we do not inherit QObject.
:param message: String for translation.
:type message: str, QString
:returns: Translated version of message.
:rtype: QString
"""
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('MapsPrinter', message)
Each time I run on MacOS, I get the previous error. But I remark that I
don't get this error if in the saveFile function, instead of
progress.setLabelText(self.tr( u'Exporting maps from {}…'.format(title) ))
I put
progress.setLabelText(self.tr( 'Exporting maps from {}…'.format(title) ))
All goes well except that I can't manage special characters and therefore
can encounter an UnicodeEncodeError error (on both platforms). But it never
complains about QCoreApplication.translate function.
Traceback (most recent call last):
File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
368, in saveFile
progress.setLabelText(self.tr( 'Exporting maps from {}…'.format(title)
))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 11: ordinal not in range(128)
Any idea is welcome.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150415/91399f4b/attachment.html>
More information about the Qgis-developer
mailing list