我正在 xbmc 上使用我自己的 python 脚本运行四个图像。我已经使用 keymap.xml 设置了键盘控件,因为我想在按下键盘上的左箭头时更改 python 中的图像。
我正在使用 xml 文件来存储图像的解析器路径。
这是我使用的 xml 文件:
<?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>
这是python脚本:
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')
当我按下键盘上的左箭头按钮时,我可以传递 if 语句,因为图像Image 2.png
存在。现在我想将我想要将其从 Image 2.png 更改为 Image 3.png 的图像更改。
有谁知道我该怎么做?