0

我正在为 xbmc 程序使用 python 脚本,我可以毫无问题地打开 addons.py,但我无法从 addons.py 打开 test.py。我目前在两个不同的文件 addons.py 和 test.py 上使用代码。

插件.py:

import xbmcgui
import xbmcaddon
import buggalo
from test import MyClass

buggalo.SUBMIT_URL = 'http://tommy.winther.nu/exception/submit.php'

try:
    w = xbmcgui.WindowXML( "script-tvguide-mainmenu.xml", xbmcaddon.Addon().getAddonInfo('path'), "Default" )
    w.doModal()
    del w
    print 'Hello!'

    mydisplay = MyClass()
    mydisplay.doModal()

except Exception:
    buggalo.onExceptionRaised()

测试.py:

print "hello!"
import xbmc 
import xbmcgui

#get actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4

class MyClass(xbmcgui.WindowXML):
  def onAction(self, action):
    if action == ACTION_MOVE_LEFT:
      print "You have press on the left arrow button!"
      self.close()

    if action == ACTION_MOVE_RIGHT:
      print "You have press on the right arrow button!"
      self.close()

    if action == ACTION_MOVE_UP:
      print "You have press on the up arrow button!"
      self.close()

    if action == ACTION_MOVE_DOWN:
      print "You have press on the down arrow button!"
      self.close()

我真的需要你的帮助,因为当我打开 addons.py 时,我无法从 addons.py 打开 test.py。它会给我一个错误function takes at least 2 arguments (0 given)。我不知道该怎么办。

这是日志: http: //pastebin.com/Qacy0UnA

有谁知道我如何从 addons.py 脚本打开 test.py ?

4

2 回答 2

0

16:55:23 T:4196 错误:mydisplay = MyClass()
16:55:23 T:4196 错误:TypeError:函数至少需要 2 个参数(给定 0)

挖掘文档xbmcgui.WindowXML并查看构造函数参数是什么。

于 2014-01-07T17:30:30.350 回答
0

改变

mydisplay = MyClass()

mydisplay = MyClass("script-tvguide-mainmenu.xml", xbmcaddon.Addon().getAddonInfo('path'))

这是因为WindowXML的超类MyClass有两个参数,文件名和路径。它在http://mirrors.xbmc.org/docs/python-docs/stable/xbmcgui.html#WindowXML中有很好的定义

于 2014-01-07T17:42:46.277 回答