Global name 'ui' not defined

Hi everyone,
I have this code for authentication but I don't understand where the 'ui.openContextMenu' comes from. I searched the internet but I can't find what it is. Anyways, it throws me the error ' global name ui is not defined'.

When posting code, please post the code itself, either using the preformatted text tool :
image
or enclosing your code in triple backtick (you can even specify the language to enable syntax coloring):

```python
code here
```

So, from what I understand this is not your code, you inherited it and you don't understand what things do ?

Well in any case, the error is quite clear: There's nothing named ui in the scope of this script. So you can't use it.
I can think of 2 reasons why it's there:

  • there used to be something named ui (either defined here or imported) but it was removed
  • the line has been partially deleted and ui was the name/part of the name of a method on another object. Though I can't see anything in this script that fits the bill.

PS:

<> None

Please don't. Aside from the fact that I really don't like this syntax, which is purely personal, it's been deprecated for a few centuries and probably shouldn't have been part of any standard in the first place.
Anyway, when comparing to None, use is and is not:

foo is None
bar is not None

check your project script library

https://docs.inductiveautomation.com/display/DOC81/Project+Library

2 Likes