Advertisement
Guest User

Untitled

a guest
Sep 4th, 2010
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.44 KB | None | 0 0
  1.  
  2. import os
  3. from traceback import print_exc
  4.  
  5. import xbmc
  6. import xbmcgui
  7. try: from xbmcaddon import Addon
  8. except : pass
  9.  
  10. CWD = os.getcwd()
  11.  
  12. try: __settings__ = Addon( os.path.basename( CWD ) )
  13. except: __settings__ = xbmc.Settings( os.getcwd() )
  14. SPECIAL_PROFILE_DIR = xbmc.translatePath( "special://profile/" )
  15. IMG_DIR = os.path.join( CWD , "resources" , "images" , "sports")
  16. ACTION_PREVIOUS_MENU = 10
  17.  
  18.  
  19. class MainGui( xbmcgui.WindowXMLDialog ):
  20.     # control id's
  21.     CONTROL_MAIN_LIST_START  = 50
  22.     CONTROL_MAIN_LIST_END    = 59
  23.  
  24.     def __init__( self, *args, **kwargs ):
  25.         xbmcgui.WindowXMLDialog.__init__( self, *args, **kwargs )
  26.         xbmc.executebuiltin( "Skin.Reset(AnimeWindowXMLDialogClose)" )
  27.         xbmc.executebuiltin( "Skin.SetBool(AnimeWindowXMLDialogClose)" )
  28.         self.listing = kwargs.get( "listing" )
  29.  
  30.     def onInit(self):
  31.         #self.title = self.getControl(1)
  32.         #self.title.setLabel( "bla bla bla" )
  33.         #self.sportimg = self.getControl(220)
  34.         #self.title.setLabel( GET_LOCALIZED_STRING( 32000 ) )
  35.         #On identifie la liste par son id
  36.         try :
  37.             self.img_list = self.getControl(451)
  38.         except :self.img_list = self.getControl(450)
  39.         #self.getControl(5).setVisible(False)
  40.         for image in self.listing :
  41.             listitem = xbmcgui.ListItem( image.split("/")[-1] )
  42.             listitem.setIconImage( image )
  43.             print image
  44.             self.img_list.addItem( listitem )
  45.         self.setFocus(self.img_list)
  46.         self.img_list.selectItem(-1)
  47.       #Création du dictionnaire
  48.       #self.liste_equipe = self.matchlist
  49.       #if self.liste_equipe == []:self.liste_equipe = [ {'sport': GET_LOCALIZED_STRING( 32100 ), 'A_name': '', 'B_name': ''} ]
  50.       #for equipe in self.liste_equipe :
  51.           #equipe['selection'] = 'false'
  52.       #self.listEquipe(self.liste_equipe)
  53.      
  54.       #self.sportimg.setImage(os.path.join( IMG_DIR , "%s.png" % equipe['sport'] ) )
  55.      
  56.       ######PLACE LE CODE A EXECUTER AU DEMARRAGE ICI
  57.        
  58.        
  59.     ######PLACE TES DEF ICI
  60.  
  61.    
  62.      
  63. #     def listEquipe(self, equipes):
  64. #         self.xml_list.reset()  
  65. #         for equipe in equipes :
  66. #            
  67. #             #On crée un element de liste, avec son label
  68. #             listitem = xbmcgui.ListItem( ( "%s  %s - %s" % ( equipe['sport'] , equipe['A_name'] , equipe['B_name'] ) ).strip( " -" ) )
  69. #             #On définit la variable clicked de l'élément liste
  70. #             #listitem.setProperty( "clicked", equipe['selection'])
  71. #             #listitem.setProperty( "sport" , os.path.join( IMG_DIR , "%s.png" % equipe['sport'] ) )
  72. #             #On injecte l'élément liste à la liste xml
  73. #             print listitem.getProperty("sport")
  74. #             self.xml_list.addItem( listitem )
  75.              
  76.            
  77.     # Cette def permet de gérer les actions en fonctions de la touche du clavier pressée
  78.     def onAction(self, action):
  79.         #Close the script
  80.         if action == ACTION_PREVIOUS_MENU :
  81.             self.close()
  82.     def message(self, message):
  83.         dialog = xbmcgui.Dialog()
  84.         dialog.ok(" My message title", message)
  85.  
  86.     def onClick(self, controlID):
  87.         pass
  88.         """
  89.            Notice: onClick not onControl
  90.            Notice: it gives the ID of the control not the control object
  91.        """
  92. #         #action sur la liste
  93. #         if controlID == 200 :
  94. #             #Renvoie le numéro de l'item sélectionné
  95. #             num = self.xml_list.getSelectedPosition()
  96. #            
  97. #             #Traitement de l'information
  98. #             if self.liste_equipe[num]['selection'] == "false" :
  99. #                 self.liste_equipe[num]['selection'] = "true"
  100. #             else :
  101. #                 self.liste_equipe[num]['selection'] = "false"
  102. #             #item = self.xml_list.getSelectedItem()
  103. #             #item.setProperty( "clicked", self.liste_equipe[num]['selection'] )
  104. #            
  105. #             self.listEquipe(self.liste_equipe)
  106. #             self.xml_list.selectItem(num)
  107. #            
  108. #         if controlID == 9001 :
  109. #             matchfilter=[]
  110. #             for equipe in self.liste_equipe :
  111. #                 if equipe['selection'] == "true" :
  112. #                     selected={}
  113. #                     print "%s  %s - %s" % ( equipe['sport'] , equipe['A_name'] , equipe['B_name'] )
  114. #                     selected['sport'] = equipe['sport']
  115. #                     selected['A_name'] = equipe['A_name'].strip(" *")
  116. #                     selected['B_name'] = equipe['B_name'].strip(" *")
  117. #                     matchfilter.append(selected)
  118. #
  119. #             file( self.filterfile , "w" ).write( repr( matchfilter ) )
  120. #             self.close()
  121.            
  122.  
  123.     def onFocus(self, controlID):
  124.         pass
  125.        
  126.        
  127. #     def _close_dialog( self ):
  128. #         for id in range( self.CONTROL_MAIN_LIST_START, self.CONTROL_MAIN_LIST_END + 1 ):
  129. #             try:
  130. #                 if xbmc.getCondVisibility( "Control.IsVisible(%i)" % id ):
  131. #                     __settings__.setSetting( "view_mode", str( id - 50 ) )
  132. #                     break
  133. #             except:
  134. #                 pass
  135. #         import time
  136. #         xbmc.executebuiltin( "Skin.Reset(AnimeWindowXMLDialogClose)" )
  137. #         time.sleep( .4 )
  138. #         self.close()
  139.  
  140.  
  141. def getUserSkin():
  142.     current_skin = xbmc.getSkinDir()
  143.     force_fallback = os.path.exists( os.path.join( CWD, "resources", "skins", current_skin) )
  144.     if not force_fallback: current_skin = "DefaultSkin"
  145.     return current_skin, force_fallback
  146.  
  147.  
  148. def MyDialog(tv_list):
  149.     current_skin, force_fallback = getUserSkin()
  150.     #"MyDialog.xml", CWD, current_skin, force_fallback sert a ouvrir le xml du script
  151.     try: w = MainGui( "FileBrowser.xml", CWD, current_skin, "720p", force_fallback , listing=tv_list )
  152.     except: w = MainGui( "FileBrowser.xml", CWD, current_skin, force_fallback , listing=tv_list )
  153.     w.doModal()
  154.     del w
  155.  
  156.  
  157. def test():
  158.     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']
  159.  
  160.     MyDialog(tv_list)
  161.  
  162. test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement