Re: A global plugin problem
toggle quoted messageShow quoted text
Ok that makes since. And it works partly. I also need to use the PIL library so when I did the old plugin I put the package for PIL and the package for aenum in the folder. And then referenced them just like I would any other time. Now that is not working. The following is the code I used before what do I need to do now. Is there a better way to include two packages that are not installed with NVDA.
PLUGIN_DIR = os.path.dirname(__file__)
# Add bundled copy of PIL to module search path.
I have another set of this code in graphit.py to import from aenum but it used to be
From aenum import IntFlag
From aenum import enum
Now that will not work. I tried doing all kinds of things for the above problem but I am at a loss how to fix it. Is there a way to install packages into plugins now or is there some python way to fix this.
From: firstname.lastname@example.org <email@example.com> On Behalf Of Joseph Lee
Sent: Friday, January 14, 2022 10:17 PM
Subject: Re: [nvda-addons] A global plugin problem
You must use relative import like so:
from . import modname
This, by the way, also works in Python 2.
I don’t mind saying exactly what it is. I do wish there was a generic answer. This is to fix the Graphiti plugin. It is for a demo unit. My file structure right now looks something like this
The code in __init__.py looks like:
The graphiti class is the driver for the device. I use it in other programs with no problem just like this and it worked when I used it in the global plugin for the older version of NV DA. I have updated the Graphiti.py and the __init__.py and the __init__.py works if I replace the use of the graphiti.py with messages to test it. The error in the log is on the line where the import graphiti is and the log says it can’t find the graphiti module.
From: firstname.lastname@example.org <email@example.com> On Behalf Of Travis Roth
I think this changed in python3 and I usually have to mess around until it works. I don’t know the directory structure you have, but for something like
If you then have __init__.py and myModule.py and myFunctions.py you need to tell it to look in the current directory for other files in that folder such as
from .myFunctions import makeBraille, makeSpeech
I have an old global plug in for before NVDA was switched to 3.x It worked fine and I have fixed all the problems that have to do with the difference in python types.
Here is the problem I have several python files in the global plugin. The
__init__.py file has an import like this:
Then there is a file in the same folder
The global plugin can not find the file I am importing. It used to work fine is there some new thing I have to do to let the global plugin know where my other classes are? Note I have my global plugin in a folder like myplugin under the developer scratchpad folder and I know it is at least being found because if I take the class I am importing out the key press works fine and presents the message I want it to. In the log though it says it can’t find myclass module.