1

Can somebody explain the following line:

self.menu = self.tr(u'&TestPlugin')

I don't understand what is in the parentheses: the small u and the need for the apostrophes. This line was created automatically in the plugin builder and while it works fine in pycharm it causes an error in pydev and therefore not enabling me to debug.The error states:

Description Resource    Path    Location    Type
Encountered "\'&TestPlugin\'" at line 72, column 30. Was expecting one of:     "(" ...     ")" ...     "[" ...     "," ...     "." ...     "+" ...     "-" ...     "*" ...     "/" ...     "//" ...     "<<" ...     ">>" ...     "%" ...     "^" ...     "|" ...     "&" ...     ">" ...     "<" ...     "==" ...     "<=" ...     ">=" ...     "!=" ...     "or" ...     "and" ...     "not" ...     "is" ...     "in" ...     "if" ...     "for" ...     "," ...     "," ...         TestPlugin.py   /test2/test - Copy  line 71 Problem

Is there a way to make pycharm ignore the error so I can continue debugging? I tried adding:

#@UnusedVariable

At the end of the line but it didn't work.

Perhaps there is something wrong with the interpreter Or I need to add an import?

closed as off-topic by user2856, xunilk, whyzar, BERA, Fezter Apr 3 '18 at 5:26

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

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    self.tr means translate (usually) in pyqgis, u'SomeString' means a unicode string (as it's a string, the apostrophes are required) and the & ampersand character is probably a menu accelerator/shortcut key. – user2856 Mar 27 '18 at 6:10
  • 1
    @Luke, I think that comment could qualify as an answer. – Fezter Mar 27 '18 at 6:24
  • @fetzer it's not a complete answer, I didn't address the error. – user2856 Mar 27 '18 at 7:17

Browse other questions tagged or ask your own question.