All pastes #77057 Raw Edit

Something

public python v1 · immutable
·published 2006-07-02 15:10 UTC
rendered paste body
#!/usr/bin/env pythonimport xbmc, xbmcguiimport ConfigParser, os.pathACTION_PREVIOUS_MENU  = 10config = ConfigParser.RawConfigParser()CURRENT_CATEGORY = ""BROWSE_ITEMS = Falseclass mainWindow(xbmcgui.Window):    def __init__(self):        self.List = xbmcgui.ControlList(200, 20, 500, 500)        self.adultButton = xbmcgui.ControlButton(20, 20, 200, 25, "Adult")        self.radioButton = xbmcgui.ControlButton(20, 50, 200, 25, "Radio")        self.tvButton = xbmcgui.ControlButton(20, 80, 200, 25, "TV")        self.videoButton = xbmcgui.ControlButton(20, 110, 200, 25, "Video")        self.addControl(self.adultButton)        self.addControl(self.radioButton)        self.addControl(self.tvButton)        self.addControl(self.videoButton)        self.addControl(self.List)        self.setFocus(self.adultButton)        #Button Actions        ##Down        self.adultButton.controlDown(self.radioButton)        self.radioButton.controlDown(self.tvButton)        self.tvButton.controlDown(self.videoButton)        self.videoButton.controlDown(self.adultButton)        ##Up        self.adultButton.controlUp(self.videoButton)        self.radioButton.controlUp(self.adultButton)        self.tvButton.controlUp(self.radioButton)        self.videoButton.controlUp(self.tvButton)        ##Right        self.adultButton.controlRight(self.List)        self.radioButton.controlRight(self.List)        self.tvButton.controlRight(self.List)        self.videoButton.controlRight(self.List)        ##Left        self.List.controlLeft(self.adultButton)    def onAction(self, action):        if action == ACTION_PREVIOUS_MENU:            self.close()    def onControl(self, control):        if control == self.adultButton:            self.loadSections("Adult")        elif control == self.radioButton:            self.loadSections("Radio")        elif control == self.tvButton:            self.loadSections("TV")        elif control == self.videoButton:            self.loadSections("Video")        elif control == self.List:@@            if BROWSE_ITEMS:                item = self.List.getSelectedPosition()                self.playItem(item)            else:                sect = self.List.getSelectedItem()                self.loadItems(sect.getLabel())    def loadSections(self, cat):        if cat == "Adult":            config.read("Q:\scripts\error\Adult.txt")            sections = config.sections()        elif cat == "Radio":            config.read("Q:\scripts\error\Radio.txt")            sections = config.sections()        elif cat == "TV":            config.read("Q:\scripts\error\TV.txt")            sections = config.sections()        elif cat == "Video":            config.read("Q:\scripts\error\Video.txt")            sections = config.sections()        self.List.reset()        for section in sections:            self.List.addItem(section)        CURRENT_CATEGORY = cat    def loadItems(self, sect):        config.read("Q:\scripts\error\\" + CURRENT_CATEGORY + ".txt")        max = config.getint(sect, "COUNT")        i = 1        self.List.reset()        while i <= max:            item = config.get(sect, "SITE" + str(i))            self.List.addItem(item)            i += 1        BROWSE_ITEMS = True    def playItem(self, pos):        print "I will play:"        #config.read("Q:\scripts\error\\" + CURRENT_CATEGORY + ".txt")        #config.get(CURRENT_SECTION, "URL" + str(pos))        #xbmc.Player.play(url)mydisplay = mainWindow()mydisplay.doModal()del mydisplay