Hi!
I am trying to launch a python macro from a button. But then this macro loads another py module.
The problem is that the second module has not access to XSCRIPTCONTEXT.
Right now I have 2 workarounds:
Workaround 1:
Using this in 1st module:
sys.modules['XSCRIPTCONTEXT'] = XSCRIPTCONTEXT
and this in 2nd module:
XSCRIPTCONTEXT = sys.modules.get('XSCRIPTCONTEXT')
Workaround 2:
Using this in 1st module:
imported_module.set_context(XSCRIPTCONTEXT)
and this in 2nd module:
def set_context(context):
global XSCRIPTCONTEXT
XSCRIPTCONTEXT = context
They both work. But is there a better and more direct and simpler way of doing this? What is the right way?
Thank you very much!