python add-on won't work in gotham
#1
Hello,

I wrote a basic python script to provide a gui front end, that creates a file used as a flag following the examples in the HOW-TO:Write Python Scripts for XBMC. The script works in frodo but fails in gotham. The error lines produced in the logs are :

/some/pathTopluginCode/default.py", line 73, in <module>
mydisplay = MyClass()
TypeError: function takes exactly 1 argument (0 given)
-->End of Python script error report<--


The python code is below. This thread is about the same error, but I can't seem to figure out how to apply the solution to my code....that in itself highlights how little I actually know of python programming. Any suggestions on how to clear the error?

Thanks,


Code:
import xbmc, xbmcgui
import os, sys



#get actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_PREVIOUS_MENU = 10


import datetime
now = datetime.datetime.now()


fpath = xbmc.translatePath('special://home/')


tfilename =os.path.join( fpath, "keep_media_flags" )


class MyClass(xbmcgui.Window):
  def __init__(self):
    self.strActionInfo = xbmcgui.ControlLabel(100, 120, 500, 300, '', 'font13', '0xFFFF00FF')
    self.addControl(self.strActionInfo)
    self.strActionInfo.setLabel('Push BACK (or Esc key) to quit')
    self.button0 = xbmcgui.ControlButton(250, 200, 500, 50, "Press to disable writes to VideoDatabase")
    self.addControl(self.button0)
    self.button1 = xbmcgui.ControlButton(750, 200, 500, 50, "Press to enable writes to VideoDatabase")
    self.addControl(self.button1)
    self.button0.controlRight(self.button1)
    self.button1.controlLeft(self.button0)

  def onAction(self, action):
    if action == ACTION_PREVIOUS_MENU:
      self.close()

  def onControl(self, control):
    if control == self.button0:

      #
      # create and populate the media flags file with timestamp
      #

      outfile = open(tfilename, 'a')

      outfile.write( '#####################\n' )
      outfile.write( now.strftime("%Y-%m-%d %H:%M \n") )
      outfile.write( '#####################\n' )

      self.message('You disabled VideoPlayer writes to the VideoDatabase ')

    if control == self.button1:

      #
      # remove the media flags file
      #

      os.remove( tfilename )
      self.message('You are back to the xbmc default of enabled  \n DVDPlayer writes to the VidoeDatabase')

  def message(self, message):
    dialog = xbmcgui.Dialog()
    dialog.ok(" My message title", message)

mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
Reply
#2
Not sure that post you linked to is any help as it just removes the window class entirely as it wasn't necessary in that script. It doesn't actually explain what the issue is, and I can't immediately see it either.

I don't know if this works on Gotham but it may be worth a look.

Otherwise you'll need to wait around for someone more experienced than me to answer this.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#3
Figured out the syntax problem after reviewing the Constructor Documentation for xbmcgui.Window in gotham. Maybe there is stricter syntax checking in gotham, and the default window id of -1 is no longer assumed if no window id is specified. Changing the constructor line and variable declaration cleared the syntax error and allows the add-on script to run in gotham:


def __init__(self):
def __init__(self,windowid=-1):

mydisplay = MyClass()
mydisplay = MyClass(-1)
Reply

Logout Mark Read Team Forum Stats Members Help
python add-on won't work in gotham0