Search code examples
pythonpython-2.7xbmc

function takes at least 2 arguments


I'm using a python script for xbmc program, I can open addons.py without have any problem, but I can't be able to open test.py from addons.py. I'm currently using the code on two different files addons.py and test.py.

Addons.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()

test.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()

I really need your help because when I open the addons.py, I can't be able to open the test.py from addons.py. It will give me an error of function takes at least 2 arguments (0 given). I don't know what to do.

Here is the log: http://pastebin.com/Qacy0UnA

Does anyone know how I can open the test.py from addons.py script?


Solution

  • Change

    mydisplay = MyClass()

    to

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

    This is because WindowXML, the superclass of MyClass, takes two arguments, filename and path. It is very well defined in http://mirrors.xbmc.org/docs/python-docs/stable/xbmcgui.html#WindowXML