I'm working on xbmc to run four images with my own python script. I have set up the keyboard control using keymap.xml as I want to change the images in python when pressing on the left arrow on the keyboard.
I'm using xml file to store the parser path for the images.
Here's the xml file that I use:
<?xml version="1.0" encoding="utf-8"?>
<window type="dialog">
<allowoverlay>no</allowoverlay>
<coordinates>
<system>1</system>
<posx>0</posx>
<posy>0</posy>
</coordinates>
<controls>
<control type="image" id="1">
<posx>0</posx>
<posy>0</posy>
<width>1280</width>
<height>720</height>
<texture>background-defeat.png</texture>
<animation effect="fade" start="0" end="100" time="6500">WindowOpen</animation>
</control>
<control type="image" id="2">
<description>Image 2</description>
<posx>307</posx>
<posy>7</posy>
<width>154</width>
<height>95</height>
<visible>true</visible>
<texture>Image 2.png</texture>
<animation effect="fade" start="0" end="100" time="1500">WindowOpen</animation>
</control>
<control type="image" id="3">
<description>Image 3</description>
<posx>460</posx>
<posy>7</posy>
<width>188</width>
<height>95</height>
<visible>true</visible>
<texture>Image 3.png</texture>
<animation effect="fade" start="0" end="100" time="1500">WindowOpen</animation>
</control>
<control type="image" id="4">
<description>Image 4</description>
<posx>648.5</posx>
<posy>7</posy>
<width>165</width>
<height>95</height>
<visible>true</visible>
<texture>Image 4.png</texture>
<animation effect="fade" start="0" end="100" time="1500">WindowOpen</animation>
</control>
</controls>
</window>
Here is the python script:
import xbmc
import xbmcgui
import os
#get actioncodes from keymap.xml
ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4
ACTION_PREVIOUS_MENU = 10
ACTION_BACKSPACE = 110
class MyClass(xbmcgui.WindowXML):
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
if action == ACTION_BACKSPACE:
self.close()
if action == ACTION_MOVE_LEFT:
if os.path.exists(xbmc.translatePath("special://home/addons/script.tvguide/resources/skins/Default/media/Image 2.png")):
self.strAction = xbmcgui.ControlLabel(300, 200, 600, 200, '', 'font14', '0xFF00FF00')
self.addControl(self.strAction)
self.strAction.setLabel('you are pressing on the left button. Now let change the image')
When I press the left arrow button on the keyboard, I can get pass on the if statement as the image Image 2.png
is exist. Now I would like to change the images which I want to change it from Image 2.png to Image 3.png.
Does anyone know how I could do that?