Run a python macro from extension action
Hello, I have asked a question in one of your online formation earlier this week which has been left unanswered.
I am trying to run python macros from custom buttons. I have managed to create my extension to show a custom ribbon with icons. However I have trouble linking my python macro (macro1.py, located within my extension, next to the ribbon.xml file) to the action tag.
I know the documentation contains two examples :
command="py: filemenu.OpenFile()"
command="py: hwf.frwk.test()" and
I can't see how to adapt these examples to run my macro file from the command :
Answers
-
There are different ways to do this. I would recommend including your code in procs/functions/methods in a file that you call with the "tclscript" or "script" (for python files) entry in the extension.xml file which gets run when the extension is loaded. Then those functions are available to call in the command entry.
You can also use source command to source a tcl file directly from the command entry or run to run a python file.
0