.py script for cycling actions ?
#1
hi.

Trying to create a python script that does the following:

1) On first 'i' keypress on fullscreen show the INFO action
2) On second 'i' keypress on fullscreen show the OSD action

.. then start all over ..

fullscreenvideo.py looks like :

import xbmc

myGlobal = 1

if myGlobal == 1:
   xbmc.executebuiltin("Action(Info)")
   myGlobal = 2
elif myGlobal == 2:
   xbmc.executebuiltin("Action(OSD)")
   myGlobal = 1


keyboard.xml snippet looks like:

<FullscreenVideo>
    <keyboard>            
        <i>runscript(special://masterprofile/addon_data/scripts/fullscreenvideo.py)</i>
    </keyboard>
  </FullscreenVideo>

It seems like each time my .py script is called, which does get called, the myGlobal variable is always 1.
How do I create a static variable that will keep its value each time the script is called ?

I guess a hack would be to persist the value in a file of some kind. The read the file accordingly.

Anyone out there who can help a python noob with this ?

/gibman
Reply
#2
(2018-02-04, 22:24)gibman Wrote: It seems like each time my .py script is called, which does get called, the myGlobal variable is always 1.
 well that shouldn't come as a surprise?

it's the first thing your script does when it runs, setting myGlobal to 1.

the easiest way to store persistent data would be to use a window property.
https://codedocs.xyz/xbmc/xbmc/group__py...eedded7b3e
that data will be kept when your script ends.
it will only be cleared when you quit kodi.

if you want to keep the current state even when kodi restarts,
saving it to a file would be the only option.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply

Logout Mark Read Team Forum Stats Members Help
.py script for cycling actions ?0