Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from traceback import print_exc
- import xbmc
- import xbmcgui
- try: from xbmcaddon import Addon
- except : pass
- CWD = os.getcwd()
- try: __settings__ = Addon( os.path.basename( CWD ) )
- except: __settings__ = xbmc.Settings( os.getcwd() )
- SPECIAL_PROFILE_DIR = xbmc.translatePath( "special://profile/" )
- IMG_DIR = os.path.join( CWD , "resources" , "images" , "sports")
- ACTION_PREVIOUS_MENU = 10
- class MainGui( xbmcgui.WindowXMLDialog ):
- # control id's
- CONTROL_MAIN_LIST_START = 50
- CONTROL_MAIN_LIST_END = 59
- def __init__( self, *args, **kwargs ):
- xbmcgui.WindowXMLDialog.__init__( self, *args, **kwargs )
- xbmc.executebuiltin( "Skin.Reset(AnimeWindowXMLDialogClose)" )
- xbmc.executebuiltin( "Skin.SetBool(AnimeWindowXMLDialogClose)" )
- self.listing = kwargs.get( "listing" )
- def onInit(self):
- #self.title = self.getControl(1)
- #self.title.setLabel( "bla bla bla" )
- #self.sportimg = self.getControl(220)
- #self.title.setLabel( GET_LOCALIZED_STRING( 32000 ) )
- #On identifie la liste par son id
- try :
- self.img_list = self.getControl(451)
- except :self.img_list = self.getControl(450)
- #self.getControl(5).setVisible(False)
- for image in self.listing :
- listitem = xbmcgui.ListItem( image.split("/")[-1] )
- listitem.setIconImage( image )
- print image
- self.img_list.addItem( listitem )
- self.setFocus(self.img_list)
- self.img_list.selectItem(-1)
- #Création du dictionnaire
- #self.liste_equipe = self.matchlist
- #if self.liste_equipe == []:self.liste_equipe = [ {'sport': GET_LOCALIZED_STRING( 32100 ), 'A_name': '', 'B_name': ''} ]
- #for equipe in self.liste_equipe :
- #equipe['selection'] = 'false'
- #self.listEquipe(self.liste_equipe)
- #self.sportimg.setImage(os.path.join( IMG_DIR , "%s.png" % equipe['sport'] ) )
- ######PLACE LE CODE A EXECUTER AU DEMARRAGE ICI
- ######PLACE TES DEF ICI
- # def listEquipe(self, equipes):
- # self.xml_list.reset()
- # for equipe in equipes :
- #
- # #On crée un element de liste, avec son label
- # listitem = xbmcgui.ListItem( ( "%s %s - %s" % ( equipe['sport'] , equipe['A_name'] , equipe['B_name'] ) ).strip( " -" ) )
- # #On définit la variable clicked de l'élément liste
- # #listitem.setProperty( "clicked", equipe['selection'])
- # #listitem.setProperty( "sport" , os.path.join( IMG_DIR , "%s.png" % equipe['sport'] ) )
- # #On injecte l'élément liste à la liste xml
- # print listitem.getProperty("sport")
- # self.xml_list.addItem( listitem )
- # Cette def permet de gérer les actions en fonctions de la touche du clavier pressée
- def onAction(self, action):
- #Close the script
- if action == ACTION_PREVIOUS_MENU :
- self.close()
- def message(self, message):
- dialog = xbmcgui.Dialog()
- dialog.ok(" My message title", message)
- def onClick(self, controlID):
- pass
- """
- Notice: onClick not onControl
- Notice: it gives the ID of the control not the control object
- """
- # #action sur la liste
- # if controlID == 200 :
- # #Renvoie le numéro de l'item sélectionné
- # num = self.xml_list.getSelectedPosition()
- #
- # #Traitement de l'information
- # if self.liste_equipe[num]['selection'] == "false" :
- # self.liste_equipe[num]['selection'] = "true"
- # else :
- # self.liste_equipe[num]['selection'] = "false"
- # #item = self.xml_list.getSelectedItem()
- # #item.setProperty( "clicked", self.liste_equipe[num]['selection'] )
- #
- # self.listEquipe(self.liste_equipe)
- # self.xml_list.selectItem(num)
- #
- # if controlID == 9001 :
- # matchfilter=[]
- # for equipe in self.liste_equipe :
- # if equipe['selection'] == "true" :
- # selected={}
- # print "%s %s - %s" % ( equipe['sport'] , equipe['A_name'] , equipe['B_name'] )
- # selected['sport'] = equipe['sport']
- # selected['A_name'] = equipe['A_name'].strip(" *")
- # selected['B_name'] = equipe['B_name'].strip(" *")
- # matchfilter.append(selected)
- #
- # file( self.filterfile , "w" ).write( repr( matchfilter ) )
- # self.close()
- def onFocus(self, controlID):
- pass
- # def _close_dialog( self ):
- # for id in range( self.CONTROL_MAIN_LIST_START, self.CONTROL_MAIN_LIST_END + 1 ):
- # try:
- # if xbmc.getCondVisibility( "Control.IsVisible(%i)" % id ):
- # __settings__.setSetting( "view_mode", str( id - 50 ) )
- # break
- # except:
- # pass
- # import time
- # xbmc.executebuiltin( "Skin.Reset(AnimeWindowXMLDialogClose)" )
- # time.sleep( .4 )
- # self.close()
- def getUserSkin():
- current_skin = xbmc.getSkinDir()
- force_fallback = os.path.exists( os.path.join( CWD, "resources", "skins", current_skin) )
- if not force_fallback: current_skin = "DefaultSkin"
- return current_skin, force_fallback
- def MyDialog(tv_list):
- current_skin, force_fallback = getUserSkin()
- #"MyDialog.xml", CWD, current_skin, force_fallback sert a ouvrir le xml du script
- try: w = MainGui( "FileBrowser.xml", CWD, current_skin, "720p", force_fallback , listing=tv_list )
- except: w = MainGui( "FileBrowser.xml", CWD, current_skin, force_fallback , listing=tv_list )
- w.doModal()
- del w
- def test():
- tv_list = ['http://www.xbmcstuff.com/stuff/series/C/C_85040 (5).jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040 (4).jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040 (3).jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040 (2).jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040.jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040 (1).jpg', 'http://www.xbmcstuff.com/stuff/series/C/C_85040 (0).jpg']
- MyDialog(tv_list)
- test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement