Kodi Community Forum

Full Version: How to make one button to run two scripts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

I have a button in home page and need to execute two files scripts with one onclick to work simultaneously when I click on it

How to do it?
 

I tried like this but didn't work:

            <onclick>XBMC.Runscript(special://home/addons/test.py), XBMC.Runscript(special://home/addons/test2.py)</onclick>
I did it by use two :

<onclick> </onclick>
<onclick> </onclick>

Thanks for all
You can't do that, you can only call one script.

However, you have the following options for test2.py.

1) Treat it like a module for test1.py and import it with import test2  .  This would be my preferred solution.
2) Use execfile ('test2.py')  .   Put it in test1. Hacky but works.  (this is exec() in python3)
3) Call it with os.system ('python test2.py')  . Call it from test1.py. Need to specify the full path to test2.py (as with 2).  You could also use subprocess instead of os, depending on what you want to do and how you are achieving it.
you mean for example if I want to use os.sytem I can do it like this:

in test.py

import os
os.system('/home/addons/test2.py')

?