3

独自の Python スクリプトで 4 つのイメージを実行するために xbmc に取り組んでいます。キーボードの左矢印を押したときに Python で画像を変更したいので、keymap.xml を使用してキーボード コントロールを設定しました。

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') 

キーボードの左矢印ボタンを押すと、画像Image 2.pngが存在するため、if ステートメントを渡すことができます。ここで、変更したい画像を Image 2.png から Image 3.png に変更したいと思います。

どうすればそれができるか知っている人はいますか?

4

1 に答える 1