Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properly Importing a Python Class in Autokey

I have a class of static methods that I wrote as a supplement to the AutoKey API. I would like to include these in my scripts that I write in the autokey editor, but I've not been able to quite figure it out yet as my experience with python is still limited.

Where do I put my class-name.py file to be able to import it into autokey?

like image 732
Ken Avatar asked Sep 13 '26 19:09

Ken


1 Answers

You just need to store all the python modules you're going to use with autokey under the same folder and select that folder as the User Module Folder in Preferences -> Script Engine.

For example, in the image below I've set ~/autokey as the directory where my helper modules are available:

User Module Folder

Note: The advice in the comments regarding changing PYTHONPATH/sys.path are also correct. The User Module Folder configuration basically appends the folder you select to sys.path to make the user modules available to your autokey scripts.

like image 161
jcollado Avatar answered Sep 15 '26 10:09

jcollado



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!