コード例 #1
0
ファイル: play_list_page.py プロジェクト: lstk520/launcher
class PlayListPage(Page):

    _Icons = {}
    _Selector = None
    _FootMsg = ["Nav", "Remove", "RTA", "Back", "Play/Pause"]
    _MyList = []
    _ListFont = MyLangManager.TrFont("notosanscjk15")

    _Scroller = None
    _CurSongTime = "0:0"

    _BGpng = None
    _BGwidth = 75
    _BGheight = 70

    _Scrolled = 0

    _CurSongName = ""

    def __init__(self):
        self._Icons = {}
        Page.__init__(self)
        self._CanvasHWND = None
        self._MyList = []

    def SyncList(self):
        self._MyList = []
        start_x = 0
        start_y = 0
        if myvars.Poller == None:
            return

        play_list = myvars.Poller.playlist()
        for i, v in enumerate(play_list):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFont

            if "title" in v:
                if isinstance(v["title"], (list, )):
                    li.Init(" | ".join(v["title"]))
                else:
                    li.Init(v["title"])

                if "file" in v:
                    li._Path = v["file"]

            elif "file" in v:
                li.Init(os.path.basename(v["file"]))
                li._Path = v["file"]
            else:
                li.Init("NoName")

            li._Labels["Text"]._PosX = 7
            self._MyList.append(li)

        self.SyncPlaying()

    def GObjectInterval(self):  ## 250 ms
        self.SyncPlaying()

        if self._Screen.CurPage() == self:
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        return True

    def SyncPlaying(self):
        if myvars.Poller == None:
            return

        current_song = myvars.Poller.poll()

        for i, v in enumerate(self._MyList):
            self._MyList[i]._Playing = False
            self._MyList[i]._PlayingProcess = 0

        if current_song != None:
            if "song" in current_song:
                posid = int(current_song["song"])
                if posid < len(self._MyList):  # out of index
                    self._CurSongName = self._MyList[posid]._Text

                    if "state" in current_song:
                        if current_song["state"] == "stop":
                            self._MyList[posid]._Playing = False
                        else:
                            self._MyList[posid]._Playing = True
                    if "time" in current_song:
                        self._CurSongTime = current_song["time"]
                        times_ = current_song["time"].split(":")
                        if len(times_) > 1:
                            cur = float(times_[0])
                            end = float(times_[1])
                            pros = int((cur / end) * 100.0)
                            self._MyList[posid]._PlayingProcess = pros

    def InPlayList(self, path):
        for i, v in enumerate(self._MyList):
            if v._Path == path:
                return True

    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = ListPageSelector()
        ps._Parent = self
        self._Ps = ps
        self._PsIndex = 0

        self.SyncList()
        gobject.timeout_add(850, self.GObjectInterval)

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["heart"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.AddLabel(MyLangManager.Tr("my favorite music"),
                             MyLangManager.TrFont("varela18"))
        self._BGpng.SetLableColor(MySkinManager.GiveColor('Disabled'))
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()

    def ScrollUp(self):
        if len(self._MyList) == 0:
            return
        self._PsIndex -= 1
        if self._PsIndex < 0:
            self._PsIndex = 0
        cur_li = self._MyList[self._PsIndex]
        if cur_li._PosY < 0:
            for i in range(0, len(self._MyList)):
                self._MyList[i]._PosY += self._MyList[i]._Height
            self._Scrolled += 1

    def ScrollDown(self):
        if len(self._MyList) == 0:
            return
        self._PsIndex += 1
        if self._PsIndex >= len(self._MyList):
            self._PsIndex = len(self._MyList) - 1

        cur_li = self._MyList[self._PsIndex]
        if cur_li._PosY + cur_li._Height > self._Height:
            for i in range(0, len(self._MyList)):
                self._MyList[i]._PosY -= self._MyList[i]._Height
            self._Scrolled -= 1

    def SyncScroll(self):  # show where it left
        if self._Scrolled == 0:
            return

        if self._PsIndex < len(self._MyList):
            cur_li = self._MyList[self._PsIndex]
            if self._Scrolled > 0:
                if cur_li._PosY < 0:
                    for i in range(0, len(self._MyList)):
                        self._MyList[i]._PosY += self._Scrolled * self._MyList[
                            i]._Height
            elif self._Scrolled < 0:
                if cur_li._PosY + cur_li._Height > self._Height:
                    for i in range(0, len(self._MyList)):
                        self._MyList[i]._PosY += self._Scrolled * self._MyList[
                            i]._Height

    def Click(self):
        if len(self._MyList) == 0:
            return

        cur_li = self._MyList[self._PsIndex]
        play_pos_id = myvars.Poller.play(self._PsIndex)

        self.SyncPlaying()

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def OnReturnBackCb(self):  # return from music_lib_list_page
        self.SyncList()
        self.SyncScroll()

    def KeyDown(self, event):
        if IsKeyMenuOrB(event.key):
            if myvars.Poller != None:
                myvars.Poller.stop()
                self._CurSongTime = ""
                self._CurSongName = ""

            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            self.ScrollUp()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        if event.key == CurKeys["Down"]:
            self.ScrollDown()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:  #add
            self._Screen.PushCurPage()
            self._Screen.SetCurPage(myvars.MusicLibListPage)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Y"]:  # del selected songs
            myvars.Poller.delete(self._PsIndex)
            self.SyncList()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.Click()

        if event.key == CurKeys["X"]:  # start spectrum
            myvars.SpectrumPage._Neighbor = self
            self._Screen.PushPage(myvars.SpectrumPage)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

    def Draw(self):
        self.ClearCanvas()

        if len(self._MyList) == 0:
            self._BGpng.NewCoord(self._Width / 2, self._Height / 2)
            self._BGpng.Draw()
            return
        else:
            if len(self._MyList) * ListItem._Height > self._Height:
                self._Ps._Width = self._Width - 11
                self._Ps.Draw()
                for i in self._MyList:
                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()
                self._Scroller.UpdateSize(
                    len(self._MyList) * ListItem._Height,
                    self._PsIndex * ListItem._Height)
                self._Scroller.Draw()
            else:
                self._Ps._Width = self._Width
                self._Ps.Draw()
                for i in self._MyList:

                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()
コード例 #2
0
class SoundSlider(Slider):
    OnChangeCB = None
    
    _BGpng = None
    _BGwidth = 192
    _BGheight = 173

    _NeedleSurf = None
    _Scale      = None
    _Parent     = None
    
    snd_segs = [ [0,20],[21,40],[41,50],[51,60],[61,70],[71,85],[86,90],[91,95],[96,100] ]

    
    def __init__(self):
        Slider.__init__(self)
        
    def Init(self):
        self._Width = self._Parent._Width
        self._Height = self._Parent._Height
        
        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool.GiveIconSurface("vol")
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)

        ##self._NeedleSurf = pygame.Surface( (38,12),pygame.SRCALPHA )
        
        self._Scale = MultiIconItem()
        self._Scale._MyType = ICON_TYPES["STAT"]
        self._Scale._Parent = self
        self._Scale._ImgSurf = MyIconPool.GiveIconSurface("scale")
        self._Scale._IconWidth = 82
        self._Scale._IconHeight = 63
        self._Scale.Adjust(0,0,82,63,0)
        
    def SetValue(self,vol):#pct 0-100
        for i,v in enumerate(self.snd_segs):
            if vol  >= v[0] and vol <= v[1]:
                self._Value = i # self._Value :  0 - 8
                break
        
    def Further(self):
        self._Value+=1

        if self._Value > len(self.snd_segs)-1:
            self._Value = len(self.snd_segs) -1

        vol = self.snd_segs[self._Value][0] + (self.snd_segs[self._Value][1] - self.snd_segs[self._Value][0])/2 
        
        if self.OnChangeCB != None:
            if callable(self.OnChangeCB):
                self.OnChangeCB( vol )
        
    def StepBack(self):
        self._Value-=1

        if self._Value < 0:
            self._Value = 0

        vol = self.snd_segs[self._Value][0] + (self.snd_segs[self._Value][1] - self.snd_segs[self._Value][0])/2 
        
        if self.OnChangeCB != None:
            if callable(self.OnChangeCB):
                self.OnChangeCB( vol )
    
    def Draw(self):
        
        self._BGpng.NewCoord(self._Width/2,self._Height/2 )
        self._BGpng.Draw()

        self._Scale.NewCoord(self._Width/2,self._Height/2)

        self._Scale._IconIndex = self._Value
        
        self._Scale.Draw()
コード例 #3
0
class StoragePage(Page):

    _Icons = {}
    _BGpng = None
    _BGwidth = 96
    _BGheight = 73
    _BGlabel = None
    _FreeLabel = None

    _BGmsg = "%.1fGB of %.1fGB Used"
    _DskUsg = None

    _HighColor = MySkinManager.GiveColor('High')
    _FootMsg = ["Nav.", "", "", "Back", ""]

    def __init__(self):
        Page.__init__(self)

        self._Icons = {}

    def DiskUsage(self):
        statvfs = os.statvfs('/')

        total_space = (statvfs.f_frsize *
                       statvfs.f_blocks) / 1024.0 / 1024.0 / 1024.0

        avail_space = (statvfs.f_frsize *
                       statvfs.f_bavail) / 1024.0 / 1024.0 / 1024.0

        return avail_space, total_space

    def Init(self):

        self._DskUsg = self.DiskUsage()

        self._CanvasHWND = self._Screen._CanvasHWND
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["icon_sd"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self

        self._BGpng.AddLabel(
            self._BGmsg % (self._DskUsg[1] - self._DskUsg[0], self._DskUsg[1]),
            fonts["varela15"])
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        self._BGlabel = Label()
        self._BGlabel.SetCanvasHWND(self._CanvasHWND)

        usage_percent = (self._DskUsg[0] / self._DskUsg[1]) * 100.0

        self._BGlabel.Init("%d%%" % int(usage_percent), fonts["varela25"])
        self._BGlabel.SetColor(self._HighColor)

        self._FreeLabel = Label()
        self._FreeLabel.SetCanvasHWND(self._CanvasHWND)
        self._FreeLabel.Init("Free", fonts["varela13"])
        self._FreeLabel.SetColor(self._BGlabel._Color)

    def OnLoadCb(self):
        pass

    def Draw(self):
        self.ClearCanvas()

        self._BGpng.NewCoord(self._Width / 2, self._Height / 2 - 10)
        self._BGpng.Draw()
        self._BGlabel.NewCoord(self._Width / 2 - 28, self._Height / 2 - 30)
        self._BGlabel.Draw()

        self._FreeLabel.NewCoord(self._BGlabel._PosX + 10, self._Height / 2)
        self._FreeLabel.Draw()

        #bgcolor = (238,238,238), fgcolor = (126,206,244)
        #aa_round_rect
        usage_percent = (self._DskUsg[0] / self._DskUsg[1])
        if usage_percent < 0.1:
            usage_percent = 0.1

        rect_ = midRect(self._Width / 2, self._Height - 30, 170, 17, Width,
                        Height)

        aa_round_rect(self._CanvasHWND, rect_, MySkinManager.GiveColor('Line'),
                      5, 0, MySkinManager.GiveColor('Line'))

        rect2 = midRect(self._Width / 2, self._Height - 30,
                        int(170 * (1.0 - usage_percent)), 17, Width, Height)

        rect2.left = rect_.left
        rect2.top = rect_.top

        aa_round_rect(self._CanvasHWND, rect2,
                      MySkinManager.GiveColor('Front'), 5, 0,
                      MySkinManager.GiveColor('Front'))
コード例 #4
0
class MusicLibListPage(Page):

    _Icons = {}
    _Selector = None
    _FootMsg = ["Nav", "", "Scan", "Back", "Add to Playlist"]
    _MyList = []
    _SwapMyList = []
    _ListFont = MyLangManager.TrFont("notosanscjk15")
    _MyStack = None

    _Scroller = None

    _BGpng = None
    _BGwidth = 56
    _BGheight = 70

    def __init__(self):
        Page.__init__(self)
        self._Icons = {}
        self._CanvasHWND = None
        self._MyList = []
        self._SwapMyList = []
        self._MyStack = MusicLibStack()

    def SyncList(self, path):
        if myvars.Poller == None:
            return

        alist = myvars.Poller.listfiles(path)
        if alist == False:
            print("listfiles return false")
            return

        self._MyList = []
        self._SwapMyList = []

        start_x = 0
        start_y = 0
        hasparent = 0
        if self._MyStack.Length() > 0:
            hasparent = 1
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y
            li._Width = Width
            li._Fonts["normal"] = self._ListFont
            li._MyType = ICON_TYPES["DIR"]
            li._Parent = self
            li.Init("[..]")
            self._MyList.append(li)

        for i, v in enumerate(sorted(alist)):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + (i + hasparent) * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFont
            li._MyType = ICON_TYPES["FILE"]
            li._Parent = self

            if "directory" in v:
                li._MyType = ICON_TYPES["DIR"]
                dir_base_name = os.path.basename(v["directory"])
                li.Init(dir_base_name)
                li._Path = v["directory"]
            elif "file" in v:
                bname = os.path.basename(v["file"])
                li.Init(bname)
                li._Path = v["file"]

            else:
                li.Init("NoName")

            self._MyList.append(li)

        for i in self._MyList:
            self._SwapMyList.append(i)

    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = ListPageSelector()
        ps._Parent = self
        self._Ps = ps
        self._PsIndex = 0

        self.SyncList("/")

        icon_for_list = MultiIconItem()
        icon_for_list._ImgSurf = MyIconPool._Icons["sys"]
        icon_for_list._MyType = ICON_TYPES["STAT"]
        icon_for_list._Parent = self

        icon_for_list.Adjust(0, 0, 18, 18, 0)
        self._Icons["sys"] = icon_for_list

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["empty"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.AddLabel(MyLangManager.Tr("Please upload data over Wi-Fi"),
                             MyLangManager.TrFont("varela22"))
        self._BGpng.SetLableColor(MySkinManager.GiveColor('Disabled'))
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()

    def Click(self):
        if len(self._MyList) == 0:
            return

        cur_li = self._MyList[self._PsIndex]

        if cur_li._MyType == ICON_TYPES["DIR"]:
            if cur_li._Path == "[..]":
                self._MyStack.Pop()
                self.SyncList(self._MyStack.Last())
                self._PsIndex = 0
            else:
                self._MyStack.Push(self._MyList[self._PsIndex]._Path)
                self.SyncList(self._MyStack.Last())
                self._PsIndex = 0

        if cur_li._MyType == ICON_TYPES["FILE"]:  ## add to playlist only
            myvars.Poller.addfile(cur_li._Path)
            myvars.PlayListPage.SyncList()
            print("add", cur_li._Path)

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def Rescan(self):
        self.SyncList("/")
        self._PsIndex = 0

    def KeyDown(self, event):

        if IsKeyMenuOrB(event.key) or event.key == CurKeys["Left"]:

            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            self.ScrollUp()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        if event.key == CurKeys["Down"]:
            self.ScrollDown()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        """
        if event.key == CurKeys["Right"]:
            self.FScrollDown(Step=5)
            self._Screen.Draw()
            self._Screen.SwapAndShow()
            
        if event.key == CurKeys["Left"]:
            self.FScrollUp(Step=5)
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        """

        if event.key == CurKeys["X"]:
            self.Rescan()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.Click()

    def Draw(self):
        self.ClearCanvas()
        """
        start_x = 0
        start_y = 0
        counter = 0
        
        self._MyList = []
        
        for i,v in enumerate(self._SwapMyList):
            if myvars.PlayListPage.InPlayList(v._Path):
                v._Active = True
            else:
                v._Active = False

            if v._Active == False:
                v.NewCoord(start_x, start_y+counter* ListItem._Height)
                counter+=1
                self._MyList.append(v)
        """

        if len(self._MyList) == 0:
            self._BGpng.NewCoord(self._Width / 2, self._Height / 2)
            self._BGpng.Draw()
            return

        else:
            if len(self._MyList) * ListItem._Height > self._Height:
                self._Ps._Width = self._Width - 11

                self._Ps.Draw()
                for i in self._MyList:
                    if myvars.PlayListPage.InPlayList(i._Path):
                        i._Active = True
                    else:
                        i._Active = False

                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()

                self._Scroller.UpdateSize(
                    len(self._MyList) * ListItem._Height,
                    self._PsIndex * ListItem._Height)
                self._Scroller.Draw()
            else:
                self._Ps._Width = self._Width
                self._Ps.Draw()
                for i in self._MyList:
                    if myvars.PlayListPage.InPlayList(i._Path):
                        i._Active = True
                    else:
                        i._Active = False

                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()
コード例 #5
0
class TimezoneListPage(Page):

    _Icons = {}
    _Selector = None
    _FootMsg = ["Nav", "", "", "Back", "Select"]
    _MyList = []
    _SwapMyList = []
    _ListFont = MyLangManager.TrFont("notosanscjk15")
    _MyStack = None

    _Scroller = None

    _BGpng = None
    _BGwidth = 56
    _BGheight = 70

    def __init__(self):
        Page.__init__(self)
        self._Icons = {}
        self._CanvasHWND = None
        self._MyList = []
        self._SwapMyList = []
        self._MyStack = TimeLibStack()

    def buildDirectoryList(self, path):
        elements = [{
            'name': f,
            'file_path': os.path.join(path, f),
            'is_file': os.path.isfile(os.path.join(path, f))
        } for f in os.listdir(path)]
        return elements

    def SyncList(self, path):

        alist = self.buildDirectoryList(path)
        if not alist:
            print("buildDirectoryList empty")
            return

        self._MyList = []
        self._SwapMyList = []

        start_x = 0
        start_y = 0
        hasparent = 0
        if self._MyStack.Length() > 0:
            hasparent = 1
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y
            li._Width = Width
            li._Fonts["normal"] = self._ListFont
            li._MyType = ICON_TYPES["DIR"]
            li.Init("[..]")
            self._MyList.append(li)

        for i, v in enumerate(sorted(alist)):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + (i + hasparent) * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFont
            li._MyType = ICON_TYPES["FILE"]

            if not v['is_file']:
                li._MyType = ICON_TYPES["DIR"]
            else:
                li._MyType = ICON_TYPES["FILE"]

            li.Init(v['name'])
            li._Path = v["file_path"]

            self._MyList.append(li)

        for i in self._MyList:
            self._SwapMyList.append(i)

    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = ListPageSelector()
        ps._Parent = self
        self._Ps = ps
        self._PsIndex = 0

        self.SyncList("/usr/share/zoneinfo/posix")

        icon_for_list = MultiIconItem()
        icon_for_list._ImgSurf = MyIconPool.GiveIconSurface("sys")
        icon_for_list._MyType = ICON_TYPES["STAT"]
        icon_for_list._Parent = self

        icon_for_list.Adjust(0, 0, 18, 18, 0)
        self._Icons["sys"] = icon_for_list

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool.GiveIconSurface("empty")
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.AddLabel("No timezones found on system!",
                             MyLangManager.TrFont("varela22"))
        self._BGpng.SetLableColor(MySkinManager.GiveColor('Disabled'))
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()

    def Click(self):
        if len(self._MyList) == 0:
            return

        cur_li = self._MyList[self._PsIndex]

        if cur_li._MyType == ICON_TYPES["DIR"]:
            if cur_li._Path == "[..]":
                self._MyStack.Pop()
                self.SyncList(self._MyStack.Last())
                self._PsIndex = 0
            else:
                self._MyStack.Push(self._MyList[self._PsIndex]._Path)
                self.SyncList(self._MyStack.Last())
                self._PsIndex = 0

        if cur_li._MyType == ICON_TYPES["FILE"]:  ## set the current timezone
            subprocess.call(['sudo', 'cp', cur_li._Path, '/etc/localtime'])
            #copyfile(cur_li._Path, '/etc/localtime')
            print("add", cur_li._Path)

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def Rescan(self):
        self.SyncList("/usr/share/zoneinfo/posix")
        self._PsIndex = 0

    def KeyDown(self, event):

        if IsKeyMenuOrB(event.key):

            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            self.ScrollUp()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        if event.key == CurKeys["Down"]:
            self.ScrollDown()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:
            self.FScrollDown(Step=5)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Left"]:
            self.FScrollUp(Step=5)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.Click()

    def Draw(self):
        self.ClearCanvas()

        if len(self._MyList) == 0:
            self._BGpng.NewCoord(self._Width / 2, self._Height / 2)
            self._BGpng.Draw()
            return

        else:
            if len(self._MyList) * ListItem._Height > self._Height:
                self._Ps._Width = self._Width - 11

                self._Ps.Draw()
                for i in self._MyList:
                    if False:
                        i._Active = True
                    else:
                        i._Active = False

                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()

                self._Scroller.UpdateSize(
                    len(self._MyList) * ListItem._Height,
                    self._PsIndex * ListItem._Height)
                self._Scroller.Draw()
            else:
                self._Ps._Width = self._Width
                self._Ps.Draw()
                for i in self._MyList:
                    if False:
                        i._Active = True
                    else:
                        i._Active = False

                    if i._PosY > self._Height + self._Height / 2:
                        break

                    if i._PosY < 0:
                        continue

                    i.Draw()
コード例 #6
0
ファイル: sound_page.py プロジェクト: bear454/launcher
class SoundSlider(Slider):
    OnChangeCB = None

    _BGpng = None
    _BGwidth = 192
    _BGheight = 173

    _NeedleSurf = None
    _Scale = None
    _Parent = None
    _Segs = [0, 15, 29, 45, 55, 65, 75, 90, 100]
    snd_segs = [[0, 20], [21, 40], [41, 50], [51, 60], [61, 70], [71, 85],
                [86, 90], [91, 95], [96, 100]]

    def __init__(self):
        Slider.__init__(self)

    def Init(self):
        self._Width = self._Parent._Width
        self._Height = self._Parent._Height

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["vol"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        ##self._NeedleSurf = pygame.Surface( (38,12),pygame.SRCALPHA )

        self._Scale = MultiIconItem()
        self._Scale._MyType = ICON_TYPES["STAT"]
        self._Scale._Parent = self
        self._Scale._ImgSurf = MyIconPool._Icons["scale"]
        self._Scale._IconWidth = 82
        self._Scale._IconHeight = 63
        self._Scale.Adjust(0, 0, 82, 63, 0)

    def SetValue(self, pct):  #pct 0-100

        for i, v in enumerate(self.snd_segs):
            if pct >= v[0] and pct <= v[1]:
                self._Value = i

    def Further(self):
        self._Value += 1
        if self._Value < len(self._Segs):
            if self.OnChangeCB != None:
                if callable(self.OnChangeCB):
                    self.OnChangeCB(self._Segs[self._Value])
        else:
            self._Value = len(self._Segs) - 1

    def StepBack(self):
        self._Value -= 1

        if self._Value < 0:
            self._Value = 0

        if self.OnChangeCB != None:
            if callable(self.OnChangeCB):
                self.OnChangeCB(self._Segs[self._Value])

    def Draw(self):

        self._BGpng.NewCoord(self._Width / 2, self._Height / 2)
        self._BGpng.Draw()

        self._Scale.NewCoord(self._Width / 2, self._Height / 2)

        self._Scale._IconIndex = self._Value

        self._Scale.Draw()
コード例 #7
0
class DevilutionPage(Page):
    _FootMsg = ["Nav", "Check", "Upgrade", "Back", "Play"]

    _GameName = "devilutionX"
    _GamePath = "/home/cpi/games/devilutionX"
    _GameExecutable = _GamePath + "/bin/devilutionx"
    _GameExecutableRevision = _GameExecutable + ".rev"
    _GameBuildScript = _GamePath + "/Packaging/cpi-gamesh/build.sh -t " + pipes.quote(
        os.path.dirname(os.path.abspath(__file__)))
    _GamePNG = _GamePath + "/Packaging/cpi-gamesh/Devilution.png"
    _DevilutionDiabdatmpq = "/home/cpi/.local/share/diasurgical/devilution/diabdat.mpq"
    _DevilutionDiabdatmpqPresent = False
    _GameInstalled = False

    _CiteNewUpdate = "Ahh... fresh meat!"
    _CiteCheckUpdate = "Lets search the books..."
    _CiteWelcome = "Well, what can I do for ya?"
    _CiteCompiling = "Stay awhile and listen."
    _CiteDone = "You must venture through the portal..."
    _CiteFailed = "Game Over. Better luck next time!"

    _GitURL = "https://github.com/diasurgical/devilutionX.git"
    _GitBranch = "master"
    _GitRevision = ""

    _GameIcon = None

    _Process = None
    _Labels = {}
    _Coords = {}

    _ListFontObj = MyLangManager.TrFont("varela13")
    _URLColor = MySkinManager.GiveColor('URL')
    _TextColor = MySkinManager.GiveColor('Text')

    def __init__(self):
        Page.__init__(self)

    def InitLabels(self):

        y = 15
        x = 11
        yInc = 19
        xGitRefLabelWidth = 48

        labels = \
         [["greeting",self._CiteWelcome, self._TextColor, x, y],
          ["status", "", self._URLColor, x, y + 72-yInc],
          ["comment", "", self._TextColor, x, y + 72],
          ["console_out","",self._URLColor, x, y + 72 + yInc],
          ["label_rev","GIT Revisions: ", self._TextColor, x, 132],
          ["label_git_rev","Source: ", self._TextColor, x, 151],
          ["content_git_rev","", self._URLColor, x + xGitRefLabelWidth, 151],
          ["label_bin_rev","Bin: ", self._TextColor, x, 170],
          ["content_bin_rev","", self._URLColor, x + xGitRefLabelWidth, 170]
         ]

        for i in labels:
            l = Label()
            l.SetCanvasHWND(self._CanvasHWND)
            l.Init(i[1], self._ListFontObj)
            l.SetColor(i[2])
            self._Labels[i[0]] = l

            c = SimpleNamespace()
            c.x = i[3]
            c.y = i[4]
            self._Coords[i[0]] = c

    def GitGetRevision(self):
        if not os.path.exists(self._GamePath):
            return "game not installed"
        process = subprocess.Popen("cd " + pipes.quote(self._GamePath) +
                                   "; git rev-parse HEAD",
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT,
                                   shell=True)
        self._GitRevision = process.communicate()[0].strip()
        process.wait()
        return self._GitRevision

    def ExectuableGetRevision(self):
        try:
            with open(self._GameExecutableRevision, 'r') as file:
                executableRevsion = file.read().replace('\n', '')
            return executableRevsion
        except:
            return "unknown"

    def InitGameDirectory(self):
        try:
            os.makedirs(self._GamePath)
        except:
            pass
        self.StartShellProcess("cd " + pipes.quote(self._GamePath) +
                               "; git clone --single-branch --branch " +
                               pipes.quote(self._GitBranch) + " " +
                               pipes.quote(self._GitURL) + " .")

    def CheckDevilutionMPQ(self):
        self._DevilutionDiabdatmpqPresent = os.path.isfile(
            self._DevilutionDiabdatmpq)

    def CheckGameInstalled(self):
        self._GameInstalled = os.path.isfile(self._GameExecutable)

    def UpdateFootMsg(self):
        if not self._GameInstalled:
            self._FootMsg = ["Nav", "", "Install", "Back", ""]
            self.UpdateLabel("status", "GIT Upgrade")
            self.UpdateLabel("comment", "Press X to install")
        elif not self._DevilutionDiabdatmpqPresent:
            self._FootMsg = ["Nav", "", "Upgrade", "Back", "Re-check"]
            self.UpdateLabel("status", "Gamefile diabdat.mpq missing")
            self.UpdateLabel("comment", "see readme")
        else:
            self._FootMsg = ["Nav", "", "Upgrade", "Back", "Play"]
            self.UpdateLabel("status", "Ready")
            self.UpdateLabel("comment", self._CiteDone)

    def Init(self):
        Page.Init(self)

        if self._Screen != None:
            if self._Screen._CanvasHWND != None and self._CanvasHWND == None:
                self._HWND = self._Screen._CanvasHWND
                self._CanvasHWND = pygame.Surface(
                    (self._Screen._Width, self._Screen._Height))

        if os.path.isfile(self._GamePNG):
            self._GameIcon = IconItem()
            self._GameIcon._ImageName = self._GamePNG
            self._GameIcon._MyType = ICON_TYPES["STAT"]
            self._GameIcon._Parent = self
            self._GameIcon.Adjust(290, 70, 128, 128, 0)

        self.InitLabels()
        self.CheckDevilutionMPQ()
        self.CheckGameInstalled()
        self.UpdateFootMsg()

        self.UpdateLabel("content_git_rev", self.GitGetRevision(), 24)
        self.UpdateLabel("content_bin_rev", self.ExectuableGetRevision(), 24)

    def UpdateLabel(self, label, msg, maxLen=38):
        print(label + ": " + msg)
        if len(msg) > maxLen:
            m = msg[:maxLen] + "..."
        else:
            m = msg
        self._Labels[label].SetText(m)

    def StartShellProcess(self, cmd):
        print("StartShellProcess " + cmd)
        proc = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                shell=True)
        while (True):
            line = proc.stdout.readline()
            if line:
                self.UpdateLabel("console_out", line.strip(), 48)
                self._Screen.Draw()
                self._Screen.SwapAndShow()
            if line == '' and proc.poll() is not None:
                break
        self.UpdateLabel("console_out", "")
        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def GitUpgrade(self):
        self.UpdateLabel("status", "GIT Upgrade")
        self.UpdateLabel("comment", self._CiteCheckUpdate)

        curRev = "unset"
        if not os.path.exists(self._GamePath):
            self.InitGameDirectory()
        else:
            curRev = self.GitGetRevision()
            self.StartShellProcess("cd " + pipes.quote(self._GamePath) +
                                   "; git pull")

        self._GitRevision = self.GitGetRevision()
        self.UpdateLabel("content_git_rev", self._GitRevision, 24)

        if curRev != self._GitRevision:
            self.UpdateLabel("comment", self._CiteNewUpdate)
        else:
            self.UpdateLabel("comment", self._CiteDone)

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def GitExectuableIsGitRevision(self):
        return self.GitGetRevision() == self.ExectuableGetRevision()

    def Build(self):
        self.UpdateLabel("status", "Building")
        self.StartShellProcess(self._GameBuildScript)

    def UpgradeAndBuild(self):
        self.GitUpgrade()
        self.UpdateLabel("comment", self._CiteCompiling)
        self._Screen.Draw()
        self._Screen.SwapAndShow()
        if not self.GitExectuableIsGitRevision():
            self.Build()

        self.UpdateLabel("content_git_rev", self.GitGetRevision(), 24)
        self.UpdateLabel("content_bin_rev", self.ExectuableGetRevision(), 24)

        self.UpdateLabel("status", "Done")
        if self.GitExectuableIsGitRevision():
            self.UpdateLabel("comment", self._CiteDone)
        else:
            self.UpdateLabel("comment", self._CiteFailed)

        self.CheckDevilutionMPQ()
        self.CheckGameInstalled()
        self.UpdateFootMsg()

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def KeyDown(self, event):

        if IsKeyMenuOrB(event.key):
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if self._DevilutionDiabdatmpqPresent and self._GameInstalled:
            if IsKeyStartOrA(event.key):
                pygame.event.post(
                    pygame.event.Event(RUNSYS, message=self._GameExecutable))
            if event.key == CurKeys["X"]:
                self.UpgradeAndBuild()
        elif not self._GameInstalled:
            if event.key == CurKeys["X"]:
                self.UpgradeAndBuild()
        elif not self._DevilutionDiabdatmpqPresent:
            if IsKeyStartOrA(event.key):
                self.CheckDevilutionMPQ()
                self.CheckGameInstalled()
                self.UpdateFootMsg()
                self._Screen.Draw()
                self._Screen.SwapAndShow()

    def Draw(self):
        self.ClearCanvas()

        if self._GameIcon != None:
            self._GameIcon.Draw()

        for i in self._Labels:
            if i in self._Coords:
                self._Labels[i].NewCoord(self._Coords[i].x, self._Coords[i].y)
                self._Labels[i].Draw()

        if self._HWND != None:
            self._HWND.fill(MySkinManager.GiveColor('White'))
            self._HWND.blit(
                self._CanvasHWND,
                (self._PosX, self._PosY, self._Width, self._Height))
コード例 #8
0
ファイル: __init__.py プロジェクト: scriptik/launcher
class CalendarPage(Page):

    _Icons = {}
    _BGpng  = None
    _BGwidth = 320
    _BGheight = 200
    _BGlabel  = None
    _FreeLabel = None
    month = 5
    year = 2019
    nuTxtMonth = {}


    _HighColor = MySkinManager.GiveColor('High')
    #_FootMsg    = ["Nav.","","","Back",""]
    _FootMsg    = ["Nav","","","Back","Today"]

    def __init__(self):
        Page.__init__(self)

        self._Icons = {}



    def CurMonth(self):
        global month
        global year
        global cur_monyear
        global nuTxtMonth

        nuTxtMonth = {1 : "Jan", 2 : "Feb", 3 : "Mar",
                      4 : "Apr", 5 : "May", 6 :"Jun",
                      7 : "Jul", 8 : "Aug", 9 : "Sep",
                     10 : "Oct", 11 :"Nov", 12 :"Dec",
                     }

        time = datetime.now()
        month = int(time.now().strftime('%-m'))
        year = int(time.now().strftime('%Y'))
        cur_monyear = (nuTxtMonth[month])+" "+str(year)
        cal_list = calendar.monthcalendar(time.year, time.month)
        return cur_monyear, cal_list

    def NextMonth(self):
        global month
        global year
        global cur_monyear
        global nuTxtMonth

        if month !=12:
           month = month+1
        elif month == 12:
           month = 1
           year = year+1

        cur_monyear = (nuTxtMonth[month])+" "+str(year)
        self._monyearlabel.SetText(cur_monyear)
        self._callist = calendar.monthcalendar(year, month)

    def PreMonth(self):
        global month
        global year
        global cur_monyear
        global nuTxtMonth

        if month !=1:
           month = month-1
        elif month == 1:
           month = 12
           year = year-1

        cur_monyear = (nuTxtMonth[month])+" "+str(year)
        self._monyearlabel.SetText(cur_monyear)
        self._callist = calendar.monthcalendar(year, month)

    def NextYear(self):
        global month
        global year
        global cur_monyear
        global nuTxtMonth

        year = year+1
        cur_monyear = (nuTxtMonth[month])+" "+str(year)
        self._monyearlabel.SetText(cur_monyear)
        self._callist = calendar.monthcalendar(year, month)

    def PreYear(self):
        global month
        global year
        global cur_monyear
        global nuTxtMonth

        year = year-1
        cur_monyear = (nuTxtMonth[month])+" "+str(year)
        self._monyearlabel.SetText(cur_monyear)
        self._callist = calendar.monthcalendar(year, month)

    def MarkToDay(self):
        time = datetime.now()
        dayslist = calendar.monthcalendar(time.year, time.month)
        today = int(time.strftime("%d"))

        days = []
        for x in dayslist:
            for y in x:
                days.append(y)

        todayINDEX = days.index(today)

    def GoToDay(self):
        self.CurMonth()
        self._monyearlabel.SetText(cur_monyear)
        self._callist = calendar.monthcalendar(year, month)

    def Init(self):


        self._dialog_index = 22

        self._CanvasHWND = self._Screen._CanvasHWND
        self._Width =  self._Screen._Width
        self._Height = self._Screen._Height

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["cpiCalbg5"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self

        self._monyearlabel = Label()
        self._monyearlabel.SetCanvasHWND(self._CanvasHWND)
        self._monyear, self._callist = self.CurMonth()
        self._monyearlabel.Init(self._monyear,fonts["varela15"])


        calnum = MultiIconItem()
        calnum._ImgSurf = MyIconPool._Icons["calnum"]
        calnum._MyType = ICON_TYPES["STAT"]
        calnum._Parent = self
        calnum._IconWidth = 35
        calnum._IconHeight = 26
        calnum.Adjust(0,0,134,372,0)
        self._Icons["calnum"] = calnum


    def KeyDown(self,event):
        if IsKeyMenuOrB(event.key):
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.GoToDay()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:
            self.NextMonth()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Left"]:
            self.PreMonth()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            self.NextYear()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Down"]:
            self.PreYear()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

    def Draw(self):
        self.ClearCanvas()

        self._BGpng.NewCoord(5,-30)
        self._BGpng.Draw()

        self._monyearlabel.NewCoord(230,5)
        self._monyearlabel.Draw()

        #self._Icons["calnum"].NewCoord(157,45)
        #self._Icons["calnum"]._IconIndex = self._dialog_index
        #self._Icons["calnum"].DrawTopLeft()

        ydic = {0:45, 1:74, 2:106, 3:137, 4:167}
        calrow = {0:0, 1:1, 2:2, 3:3, 4:4}
        if len(self._callist) is 4:
          for j in range(4):
              x = 40
              y = ydic[j]
              row = calrow[j]
              for numbers in self._callist[row]:
                  if numbers != 0:
                     self._Icons["calnum"].NewCoord(x,y)
                     self._Icons["calnum"]._IconIndex = numbers
                     self._Icons["calnum"].DrawTopLeft()
                  x = x+39

        else:
          for j in range(5):
              x = 40
              y = ydic[j]
              row = calrow[j]
              for numbers in self._callist[row]:
                  if numbers != 0:
                     self._Icons["calnum"].NewCoord(x,y)
                     self._Icons["calnum"]._IconIndex = numbers
                     self._Icons["calnum"].DrawTopLeft()
                  x = x+39
          if len(self._callist) is 6:
             x = 40
             for numbers in self._callist[5]:
                 if numbers != 0:
                    self._Icons["calnum"].NewCoord(x,48)
                    self._Icons["calnum"]._IconIndex = numbers
                    self._Icons["calnum"].DrawTopLeft()
                 x = x+39
コード例 #9
0
class PlayListPage(Page):

    _Icons = {}
    _Selector = None
    _FootMsg = ["Nav", "", "Remove", "Back", "Play/Pause"]
    _MyList = []
    _ListFont = fonts["notosanscjk15"]

    _Scroller = None

    _BGpng = None
    _BGwidth = 75
    _BGheight = 70

    def __init__(self):
        self._Icons = {}
        Page.__init__(self)
        self._CanvasHWND = None
        self._MyList = []

    def SyncList(self):
        self._MyList = []
        start_x = 0
        start_y = 0
        if myvars.Poller == None:
            return

        play_list = myvars.Poller.playlist()
        for i, v in enumerate(play_list):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFont

            if "title" in v:
                li.Init(v["title"])
                if "file" in v:
                    li._Path = v["file"]

            elif "file" in v:
                li.Init(os.path.basename(v["file"]))
                li._Path = v["file"]
            else:
                li.Init("NoName")

            li._Labels["Text"]._PosX = 7
            self._MyList.append(li)

        self.SyncPlaying()

    def GObjectInterval(self):  ## 250 ms
        if self._Screen.CurPage() == self:
            self.SyncPlaying()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        return True

    def SyncPlaying(self):
        if myvars.Poller == None:
            return

        current_song = myvars.Poller.poll()

        for i, v in enumerate(self._MyList):
            self._MyList[i]._Playing = False
            self._MyList[i]._PlayingProcess = 0

        if current_song != None:
            if "song" in current_song:
                posid = int(current_song["song"])
                if posid < len(self._MyList):  # out of index
                    if "state" in current_song:
                        if current_song["state"] == "stop":
                            self._MyList[posid]._Playing = False
                        else:
                            self._MyList[posid]._Playing = True
                    if "time" in current_song:
                        times_ = current_song["time"].split(":")
                        if len(times_) > 1:
                            cur = float(times_[0])
                            end = float(times_[1])
                            pros = int((cur / end) * 100.0)
                            self._MyList[posid]._PlayingProcess = pros

    def InPlayList(self, path):
        for i, v in enumerate(self._MyList):
            if v._Path == path:
                return True

    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = ListPageSelector()
        ps._Parent = self
        self._Ps = ps
        self._PsIndex = 0

        self.SyncList()
        gobject.timeout_add(850, self.GObjectInterval)

        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["heart"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.AddLabel("my favourites", fonts["varela18"])
        self._BGpng.SetLableColor(pygame.Color(204, 204, 204))
        self._BGpng.Adjust(0, 0, self._BGwidth, self._BGheight, 0)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()

    def ScrollUp(self):
        if len(self._MyList) == 0:
            return
        self._PsIndex -= 1
        if self._PsIndex < 0:
            self._PsIndex = 0
        cur_li = self._MyList[self._PsIndex]
        if cur_li._PosY < 0:
            for i in range(0, len(self._MyList)):
                self._MyList[i]._PosY += self._MyList[i]._Height

    def ScrollDown(self):
        if len(self._MyList) == 0:
            return
        self._PsIndex += 1
        if self._PsIndex >= len(self._MyList):
            self._PsIndex = len(self._MyList) - 1

        cur_li = self._MyList[self._PsIndex]
        if cur_li._PosY + cur_li._Height > self._Height:
            for i in range(0, len(self._MyList)):
                self._MyList[i]._PosY -= self._MyList[i]._Height

    def Click(self):
        if len(self._MyList) == 0:
            return

        cur_li = self._MyList[self._PsIndex]
        play_pos_id = myvars.Poller.play(self._PsIndex)

        self.SyncPlaying()

        self._Screen.Draw()
        self._Screen.SwapAndShow()

    def OnReturnBackCb(self):
        self.SyncList()

    def KeyDown(self, event):
        if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
            if myvars.Poller != None:
                myvars.Poller.stop()

            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            self.ScrollUp()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
        if event.key == CurKeys["Down"]:
            self.ScrollDown()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:  #add
            self._Screen.PushCurPage()
            self._Screen.SetCurPage(myvars.MusicLibListPage)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Y"]:  # del selected songs
            myvars.Poller.delete(self._PsIndex)
            self.SyncList()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Enter"]:
            self.Click()

        if event.key == CurKeys["Start"]:  # start spectrum
            self._Screen.PushPage(myvars.SpectrumPage)
            self._Screen.Draw()
            self._Screen.SwapAndShow()

    def Draw(self):
        self.ClearCanvas()

        if len(self._MyList) == 0:
            self._BGpng.NewCoord(self._Width / 2, self._Height / 2)
            self._BGpng.Draw()
            return
        else:
            if len(self._MyList) * ListItem._Height > self._Height:
                self._Ps._Width = self._Width - 11
                self._Ps.Draw()
                for i in self._MyList:
                    i.Draw()
                self._Scroller.UpdateSize(
                    len(self._MyList) * ListItem._Height,
                    self._PsIndex * ListItem._Height)
                self._Scroller.Draw()
            else:
                self._Ps._Width = self._Width
                self._Ps.Draw()
                for i in self._MyList:
                    i.Draw()