WindowXMLDialog with plugin.video/program
#1
Is it possible to use WindowXMLDialog with addons of type "plugin.video" and "plugin.program"? or is it just for "script" addons?
If it can be done, can you give a brief example of the file structure and initialization?

What I did is create an xml file containing a dialog "<window type="dialog" ...>", and saved it under
"PLUGIN/resources/skins/default/720p"
I also tried different paths (every possible way I could think of).
Then I initialized it with
Code:
WindowXMLDialog("dialog.xml", os.getcwd())
I also tried
Code:
WindowXMLDialog("dialog.xml", __addon__.getAddonInfo("path"))
without any luck (I did show it after init). I also tried to supply 3rd and 4th arguments (e.g. "default", "720p")
The exception I am getting is:
Code:
RuntimeError: XML File for Window is missing

Can anyone help me with this.
Reply
#2
PHP Code:
path xbmc.translatePath(os.path.join(__addon__.getAddonInfo("path") + "resources/skins/default/720p"))
WindowXMLDialog("dialog.xml"path
or something like that

os.getcwd() is not allowed
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
Thanks. But it should be a comma instead of + to join with os.path.join (otherwise it will be without separator). Even then the path becomes duplicated "PLUGIN/resources/skins/default/720p/resources/skins/Default" which is not correct. Default need to be with capital D
os.getcwd() example was in the python-docs as default example Wink

The problem wasn't in the code I quoted myself (as it was mostly correct). The problem is that I was creating new class and inheriting from xbmcgui.WindowXMLDialog, and then trying to define my own __init__ and call the super and pass the file/path internally!
Inspecting the messages before the error showed that my arguments for my class are automatically passed to WindowXMLDialog, and used as file/path, so I cannot define custom arguments and pass my own file/path internally!
What is the use of inheritance then if we are not allowed to call the super with our own values?
This is not possible
Code:
class MyDialog(xbmcgui.WindowXMLDialog):
   def __init__(self, myarg1, myarg2, myarg3):
      xbmcgui.WindowXMLDialog.__init__("dialog.xml", __addon__.getAddonInfo('path'))
      // handle my own args

d = MyDialog("a", "b", "c")
d.show()
I don't know why do I need to subclass, if I still need to pass same arguments to xbmcgui.WindowXMLDialog. Or maybe I got it all wrong?
Reply
#4
If you're not providing an xml file that describes the window, inherit from xbmcgui.WindowDialog or xbmcgui.Window instead
Reply
#5
I am in fact providing one (check the wrong scenario above, there is xml file when calling super/init), and I am going to use xml for skin anyway. I want the arguments to be handled along with the xml skin (which will be internal). This is, however, not possible as I learned.

I think the only way is to inherit, add additional method to accept my arguments, instantiate the class (passing the xml files), and then call the additional method I set for passing my own arguments. This should work, but the wrong scenario I provided seemed more logical if you are going to create a sub-class (or at least to me).

Thank you guys.
Reply
#6
Look in this Addon: http://forum.xbmc.org/showthread.php?tid=164067
I use own subclassed windowxml-classes with parameters.
Reply
#7
So it wasn't only me troubled with the current inheritance model. This is exactly what I was looking for.
Thank you so much olivaar!
Nice addon btw, I always wanted to edit tagging (along with other infos) right from the GUI.

Edit: for easier access, here is the skeleton to achieve what I preferred, and was used by olivaar:
Code:
class MyDialog(xbmcgui.WindowXMLDialog):
    def __new__(cls):
        return super(MyDialog, cls).__new__(cls, "skin_file.xml", __ADDON__.getAddonInfo('path'))

    def __init__(self):
        super(MyDialog, self).__init__()

    def setArgs(arg1, arg2, arg3)
        # handle your args (e.g. arg1, arg2, arg3, ...etc)

    # add other methods as needed
Reply

Logout Mark Read Team Forum Stats Members Help
WindowXMLDialog with plugin.video/program0