I want to use the button shim led for multiple purposes,not only for button actions.
so I created led_green.py led_red.py and so on
i.e.
led_red.py consists of :
#!/usr/bin/env python
import buttonshim
buttonshim.set_pixel(200, 0, 0)
I call the script,it sets the led red and exits
But I already discovered why this happens :
the buttonshim module gets loaded from :
/usr/local/lib/python2.7/dist-packages/buttonshim/init.pyc
the init.py there @ line 174/416 within the _quit function :
==> set_pixel(0, 0, 0)
which means as soon as a python script (that loaded the buttonshim module) exits,the led will be turned off.
When I # this line,the led stays on,but thats not good if you want to use the led for button related actions as it was original intented.
so I created a modified init.py without the quit action,sadly I fail to import this within my led scripts.
I tried to add an alternative sys path to the modified init.py,but its not working :
I placed the init.py & init.pyc in /home/pi/shortcuts/python/buttonshim
sys.path.insert(0, r’/home/pi/shortcuts/python/buttonshim’)
import buttonshim
print(buttonshim.file)
/usr/local/lib/python2.7/dist-packages/buttonshim/init.pyc
so how to use a modified init.py in certain scripts,while all other scripts that use “import buttonshim” import the original version ?