2018-04-29, 14:00
Hi every body,
So this is my python code I use to learn video addon plugin :
When I launch my video all it is ok, my video works, but I would like to update this code to add a dialog box.
When I click on my video I would like that a box appears with three buttons, the first must be Play, the second Trailer, and the third Exit, I would like to add the synopsis of my video and finally a Fanart in background.
My first question is : What is the type of dialog box can I use ?
My second question is : Where I must call the dialog box in my code ?
Actually I know create a simple dialog box :
But with this dialog box I can not change the background, or maybe I am wrong.
Thanks a lot for your help.
So this is my python code I use to learn video addon plugin :
python:
# -*- coding: utf-8 -*-
import sys
import os
from urllib import urlopen
import urllib
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import logging
import operator
def show_tags():
tag_handle = int(sys.argv[1])
xbmcplugin.setContent(tag_handle, 'tags')
for tag in tags:
logging.warning('# tag is : %s', tag)
iconPath = os.path.join(home, 'logos', tag['icon'])
logging.warning('#icon path : %s', iconPath)
li = xbmcgui.ListItem(tag['name'], iconImage=iconPath)
logging.warning('# li ListItem : %s', li)
url = sys.argv[0] + '?tag=' + str(tag['id'])
xbmcplugin.addDirectoryItem(handle=tag_handle, url=url, listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(tag_handle)
def show_streams(tag):
stream_handle = int(sys.argv[1])
xbmcplugin.setContent(stream_handle, 'streams')
logging.warning('TAG show_streams!!!! %s', tag)
for stream in streams[str(tag)]:
logging.debug('STREAM HERE!!! %s', stream['name'].encode('utf-8'))
iconPath = os.path.join(home, 'logos/jaquettes', stream['icon'])
li = xbmcgui.ListItem(stream['name'].encode('utf-8'), iconImage=iconPath)
xbmcplugin.addDirectoryItem(handle=stream_handle, url=stream['url'], listitem=li)
xbmcplugin.endOfDirectory(stream_handle)
def get_params():
"""
Retrieves the current existing parameters from XBMC.
"""
param =
paramstring = sys.argv[2]
if len(paramstring) >= 2:
params = sys.argv[2]
cleanedparams = params.replace('?', '')
if params[len(params) - 1] == '/':
params = params[0:len(params) - 2]
pairsofparams = cleanedparams.split('&')
param = {}
for i in range(len(pairsofparams)):
splitparams = {}
splitparams = pairsofparams.split('=')
if (len(splitparams)) == 2:
param[splitparams[0]] = splitparams[1]
return param
def fctSortDict(value):
return value['id']
addon = xbmcaddon.Addon()
home = xbmc.translatePath(addon.getAddonInfo('path'))
tags = [
{
'name': 'Movies',
'id': 'Movies',
'icon': 'movies.png'
}
]
Movies =
{
'id' : 1,
'name' : 'Voyage to the Planet of Prehistoric Women',
'url' : 'https://archive.org/details/VoyagetothePlanetofPrehistoricWomen',
'icon' : 'http://www.gstatic.com/tv/thumb/dvdboxart/45773/p45773_d_v8_aa.jpg',
'disabled' : False
}
streams = {
'Movies' : sorted((i for i in Movies if not i.get('disabled', False)), key=fctSortDict, reverse=False)
}
PARAMS = get_params()
TAG = None
logging.warning('PARAMS!!!! %s', PARAMS)
try:
TAG = PARAMS['tag']
except:
pass
logging.warning('ARGS!!!! sys.argv %s', sys.argv)
if TAG == None:
show_tags()
else:
show_streams(TAG)
When I launch my video all it is ok, my video works, but I would like to update this code to add a dialog box.
When I click on my video I would like that a box appears with three buttons, the first must be Play, the second Trailer, and the third Exit, I would like to add the synopsis of my video and finally a Fanart in background.
My first question is : What is the type of dialog box can I use ?
My second question is : Where I must call the dialog box in my code ?
Actually I know create a simple dialog box :
python:
import xbmc
import xbmcgui
dialog = xbmcgui.Dialog()
choice = dialog.yesno('TITLE OF THE DIALOG BOX', 'Message on the dialog box', yeslabel='YES', nolabel='NO')
if choice == 1:
dialog.ok('TITLE OF THE DIALOG BOX YES', 'Message on the dialog box YES')
else:
dialog.ok('TITLE OF THE DIALOG BOX NO', 'Message on the dialog box NO')
But with this dialog box I can not change the background, or maybe I am wrong.
Thanks a lot for your help.