示例#1
0
    def Init(self, text):

        #self._Fonts["normal"] = fonts["veramono12"]

        l = Label()
        l._PosX = 20
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        if self._MyType == ICON_TYPES["DIR"] or self._MyType == ICON_TYPES[
                "FILE"]:
            self._Path = text

        label_text = os.path.basename(text)
        alias_file = os.path.splitext(text)[0] + ".alias"
        if os.path.isfile(alias_file):
            fp = open(alias_file, "r")
            alias = fp.read()
            fp.close()
            label_text = alias.decode("utf8")

        if self._MyType == ICON_TYPES["DIR"]:
            l.Init(label_text, self._Fonts["normal"])
        else:
            l.Init(label_text, self._Fonts["normal"])

        self._Labels["Text"] = l
示例#2
0
    def Init(self, text):
        l = Label()
        l._PosX = 16
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        l.Init(text, self._Fonts["normal"])
        self._Labels["Text"] = l
示例#3
0
    def SetLabels(self):
        if is_wifi_connected_now():
            self._IP = get_wifi_ip()
            print("TinyCould : %s" % self._IP)
            try:
                if validators.ip_address.ipv4(self._IP) == False:
                    self._IP = "xxx.xxx.xxx.xxx"
            except:
                print("ip error %s " % self._IP)
                self._IP = "xxx.xxx.xxx.xxx"

        else:
            self._IP = "xxx.xxx.xxx.xxx"

        labels = \
        [["forssh","For ssh and scp:",self._ListFontObj,self._TextColor],
         ["ssh_addr","ssh cpi@%s" % self._IP, self._ListFontObj,self._URLColor],
         ["forwin", "For Windows network:",    self._ListFontObj, self._TextColor],
         ["samba_games", "\\\\%s\games" % self._IP, self._ListFontObj,self._URLColor],
         ["samba_music", "\\\\%s\music" % self._IP, self._ListFontObj,self._URLColor],
         ["forID",      "ID:",                     self._ListFontObj, self._TextColor],
         ["forKey",     "Key:",                    self._ListFontObj, self._TextColor],
         ["key_and_pass", "cpi",                   self._ListFontObj, self._URLColor],
         ["for_airplay", "Airplay:",               self._ListFontObj, self._TextColor],
         ["airplay_name","clockworkpi",            self._ListFontObj, self._URLColor]]

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

        self.SetCoords()  ##
示例#4
0
    def SetSmallText(self, text):

        l = Label()
        l._PosX = 40
        l.SetCanvasHWND(self._Parent._CanvasHWND)
        l.Init(text, self._Fonts["small"])
        self._Labels["Small"] = l
示例#5
0
    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
示例#6
0
    def Init(self, text):

        l = Label()
        l._PosX = 10
        l.SetCanvasHWND(self._Parent._CanvasHWND)
        text = MyLangManager.Tr(text)
        l.Init(text, self._Fonts["normal"])
        self._Labels["Text"] = l
示例#7
0
    def Init(self,text):

        #self._Fonts["normal"] = fonts["veramono12"]
        
        l = Label()
        l._PosX = 10
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        l.Init(text,self._Fonts["normal"])
        self._Labels["Text"] = l
示例#8
0
    def Init(self, text):

        #self._Fonts["normal"] = fonts["veramono12"]

        l = Label()
        l._PosX = 20
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        if self._MyType == ICON_TYPES["DIR"] or self._MyType == ICON_TYPES[
                "FILE"]:
            self._Path = text

        label_text = os.path.basename(text)

        if self._MyType == ICON_TYPES["DIR"]:
            l.Init(label_text, self._Fonts["normal"])
        else:
            l.Init(label_text, self._Fonts["normal"])

        self._Labels["Text"] = l
示例#9
0
    def Init(self, text):

        #self._Fonts["normal"] = fonts["veramono12"]

        l = Label()
        l._PosX = 10
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        l.Init(text, self._Fonts["normal"])
        self._Labels["Text"] = l

        add_icon = IconItem()
        add_icon._ImgSurf = MyIconPool.GiveIconSurface("add")
        add_icon._CanvasHWND = self._CanvasHWND
        add_icon._Parent = self
        add_icon.Init(0, 0, MyIconPool.Width("add"), MyIconPool.Height("add"),
                      0)

        ware_icon = IconItem()
        ware_icon._ImgSurf = MyIconPool.GiveIconSurface("ware")
        ware_icon._CanvasHWND = self._CanvasHWND
        ware_icon._Parent = self
        ware_icon.Init(0, 0, MyIconPool.Width("ware"),
                       MyIconPool.Height("ware"), 0)

        app_icon = IconItem()
        app_icon._ImgSurf = MyIconPool.GiveIconSurface("app")
        app_icon._CanvasHWND = self._CanvasHWND
        app_icon._Parent = self
        app_icon.Init(0, 0, MyIconPool.Width("app"), MyIconPool.Height("app"),
                      0)

        appdling_icon = IconItem()
        appdling_icon._ImgSurf = MyIconPool.GiveIconSurface("appdling")
        appdling_icon._CanvasHWND = self._CanvasHWND
        appdling_icon._Parent = self
        appdling_icon.Init(0, 0, MyIconPool.Width("appdling"),
                           MyIconPool.Height("appdling"), 0)

        blackheart_icon = IconItem()
        blackheart_icon._ImgSurf = MyIconPool.GiveIconSurface("blackheart")
        blackheart_icon._Width = MyIconPool.Width("blackheart")
        blackheart_icon._Height = MyIconPool.Height("blackheart")
        blackheart_icon._CanvasHWND = self._CanvasHWND
        blackheart_icon._Parent = self

        self._Icons["add"] = add_icon
        self._Icons["ware"] = ware_icon
        self._Icons["app"] = app_icon
        self._Icons["appdling"] = appdling_icon
        self._Icons["blackheart"] = blackheart_icon
示例#10
0
class BatteryPage(Page):

    _FootMsg = ["Nav", "", "Refresh", "Back", "Enter"]
    _Label = None

    def Init(self):
        self._CanvasHWND = self._Screen._CanvasHWND
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._Label = Label()
        self._Label.SetCanvasHWND(self._CanvasHWND)
        self._Label.Init('', MySkinManager.GiveFont('varela25'))

    def _update_percent(self):
        self._Label.SetText('%s %%' % get_battery_percent())
        rect = midRect(self._Width / 2, self._Height / 2, self._Label._Width,
                       self._Label._Height, Width, Height)
        self._Label.NewCoord(rect.left, rect.top)

    def OnLoadCb(self):
        self._update_percent()

    def KeyDown(self, event):
        if event.key == CurKeys["Menu"] or event.key == CurKeys["B"]:
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

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

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

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

    def Draw(self):
        self.ClearCanvas()
        self._Label.Draw()
示例#11
0
    def Init(self, text):

        #self._Fonts["normal"] = fonts["veramono12"]
        self._CanvasHWND = self._Parent._CanvasHWND

        l = Label()
        l._PosX = 10
        l.SetCanvasHWND(self._Parent._CanvasHWND)

        l.Init(text, self._Fonts["normal"])
        self._Labels["Text"] = l

        done_icon = IconItem()
        done_icon._ImgSurf = MyIconPool._Icons["done"]
        done_icon._CanvasHWND = self._Parent._CanvasHWND
        done_icon._Parent = self

        self._Icons["done"] = done_icon
示例#12
0
    def Init(self, path, object):
        self._Path = path
        self._Atts = object

        is_active = False
        if "Address" in object:
            self._MacAddr = object["Address"]

        if "Connected" in object:
            if object["Connected"] == 1:
                is_active = True

        if is_active:
            self.SetActive(is_active)

        name_label = Label()
        name_label._PosX = 12
        name_label._CanvasHWND = self._Parent._CanvasHWND

        mac_addr = self._MacAddr

        if "Name" in object:
            if len(object["Name"]) > 3:
                mac_addr = object["Name"]

        if "RSSI" in object:
            print(object["RSSI"])
            self._RSSI = int(object["RSSI"])

        mac_addr = mac_addr[:34]

        name_label.Init(mac_addr, self._FontObj)

        self._Labels["mac_addr"] = name_label

        done_icon = NetItemIcon()
        done_icon._ImgSurf = MyIconPool.GiveIconSurface("done")
        done_icon._CanvasHWND = self._Parent._CanvasHWND
        done_icon._Parent = self

        self._Icons["done"] = done_icon
示例#13
0
class Aria2DownloadProcessPage(Page):
    _FootMsg = ["Nav.", "", "Pause", "Back", "Cancel"]
    _DownloaderTimer = -1
    _Value = 0
    _GID = None

    _PngSize = {}

    _FileNameLabel = None
    _SizeLabel = None

    _URLColor = MySkinManager.GiveColor('URL')
    _TextColor = MySkinManager.GiveColor('Text')

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

    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

        bgpng = IconItem()
        bgpng._ImgSurf = MyIconPool.GiveIconSurface("rom_download")
        bgpng._MyType = ICON_TYPES["STAT"]
        bgpng._Parent = self
        bgpng.Adjust(0, 0, self._PngSize["bg"][0], self._PngSize["bg"][1], 0)
        self._Icons["bg"] = bgpng

        self._FileNameLabel = Label()
        self._FileNameLabel.SetCanvasHWND(self._CanvasHWND)
        self._FileNameLabel.Init("", MyLangManager.TrFont("varela12"))

        self._SizeLabel = Label()
        self._SizeLabel.SetCanvasHWND(self._CanvasHWND)
        self._SizeLabel.Init("0/0Kb", MyLangManager.TrFont("varela12"))
        self._SizeLabel.SetColor(self._URLColor)

    @property
    def GObjectUpdateProcessInterval(self):
        downloaded = 0
        if self._Screen.CurPage() == self and self._GID is not None:
            self._Value = config.RPC.tellStatus(self._GID)

            downloaded = 0
            total = 0

        if self._Value["status"] == "waiting":
            self._FileNameLabel.SetText("waiting to download...")
        if self._Value["status"] == "paused":
            self._FileNameLabel.SetText("download paused...")
        if self._Value["status"] == "error":
            self._FileNameLabel.SetText("download errors,cancel it please")

        if self._Value["status"] == "active":
            downloaded = self._Value["completedLength"]
            total = self._Value["totalLength"]

            downloaded = downloaded / 1000.0 / 1000.0
            total = total / 1000.0 / 1000.0

        self._SizeLabel.SetText("%.2f" % downloaded + "/" + "%.2f" % total +
                                "Mb")

        print("Progress: %d%%" % (self._Value))
        self._Screen.Draw()
        self._Screen.SwapAndShow()
        return True

    def CheckDownload(self, aria2_gid):
        self._GID = aria2_gid
        self._DownloaderTimer = gobject.timeout_add(
            234, self.GObjectUpdateProcessInterval)

    def KeyDown(self, event):
        if IsKeyMenuOrB(event.key):
            gobject.source_remove(self._DownloaderTimer)
            self._DownloaderTimer = -1

            #if self._Downloader != None:
            #    try:
            #        self._Downloader.stop()
            #    except:
            #        print("user canceled ")

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

    def Draw(self):
        self.ClearCanvas()

        self._Icons["bg"].NewCoord(self._Width / 2, self._Height / 2 - 20)
        self._Icons["bg"].Draw()

        percent = self._Value
        if percent < 10:
            percent = 10

        rect_ = midRect(self._Width / 2, self._Height / 2 + 33, 170, 17, Width,
                        Height)
        aa_round_rect(self._CanvasHWND, rect_,
                      MySkinManager.GiveColor('TitleBg'), 5, 0,
                      MySkinManager.GiveColor('TitleBg'))

        rect2 = midRect(self._Width / 2, self._Height / 2 + 33,
                        int(170 * (percent / 100.0)), 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'))

        rect3 = midRect(self._Width / 2, self._Height / 2 + 53,
                        self._FileNameLabel._Width,
                        self._FileNameLabel._Height, Width, Height)

        rect4 = midRect(self._Width / 2, self._Height / 2 + 70,
                        self._SizeLabel._Width, self._SizeLabel._Height, Width,
                        Height)

        self._FileNameLabel.NewCoord(rect3.left, rect3.top)
        self._SizeLabel.NewCoord(rect4.left, rect4.top)

        self._FileNameLabel.Draw()
        self._SizeLabel.Draw()
示例#14
0
class DownloadProcessPage(Page):
    _FootMsg = ["Nav.", "", "", "Back", ""]
    _Downloader = None
    _DownloaderTimer = -1
    _Value = 0

    _URL = ""
    _DST_DIR = ""

    _PngSize = {}

    _FileNameLabel = None
    _SizeLabel = None

    _URLColor = MySkinManager.GiveColor('URL')
    _TextColor = MySkinManager.GiveColor('Text')

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

    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

        self._PngSize["bg"] = (48, 79)
        self._PngSize["needwifi_bg"] = (253, 132)

        bgpng = IconItem()
        bgpng._ImgSurf = MyIconPool._Icons["rom_download"]
        bgpng._MyType = ICON_TYPES["STAT"]
        bgpng._Parent = self
        bgpng.Adjust(0, 0, self._PngSize["bg"][0], self._PngSize["bg"][1], 0)
        self._Icons["bg"] = bgpng

        needwifi_bg = IconItem()
        needwifi_bg._ImgSurf = MyIconPool._Icons["needwifi_bg"]
        needwifi_bg._MyType = ICON_TYPES["STAT"]
        needwifi_bg._Parent = self
        needwifi_bg.Adjust(0, 0, self._PngSize["needwifi_bg"][0],
                           self._PngSize["needwifi_bg"][1], 0)

        self._Icons["needwifi_bg"] = needwifi_bg

        self._FileNameLabel = Label()
        self._FileNameLabel.SetCanvasHWND(self._CanvasHWND)
        self._FileNameLabel.Init("", MyLangManager.TrFont("varela12"))

        self._SizeLabel = Label()
        self._SizeLabel.SetCanvasHWND(self._CanvasHWND)
        self._SizeLabel.Init("0/0Kb", MyLangManager.TrFont("varela12"))
        self._SizeLabel.SetColor(self._URLColor)

    def OnExitCb(self, event):
        print("DownloadProcessPage OnExitCb")
        if self._Downloader == None:
            return
        try:
            self._Downloader.stop()
        except:
            pass
        return

    def GObjectUpdateProcessInterval(self):
        if self._Screen.CurPage() == self:
            if self._Downloader.isFinished():
                if self._Downloader.isSuccessful():
                    print("Success!")
                    # Do something with obj.get_dest()
                    filename = os.path.basename(self._Downloader.get_dest())
                    cur_dir = os.getcwd()

                    if filename.endswith(".zip"):
                        os.chdir(self._DST_DIR)
                        os.system("unzip " + filename)

                    elif filename.endswith(".zsync"):
                        os.chdir(self._DST_DIR)
                        os.system("rm -rf " + filename)

                    elif filename.endswith(".tar.xz"):
                        os.chdir(self._DST_DIR)
                        os.system("tar xf " + filename)
                        os.system("rm -rf " + filename)

                    os.chdir(cur_dir)
                    self.ReturnToUpLevelPage()
                    self._Screen.Draw()
                    self._Screen.SwapAndShow()

                else:
                    print("Download failed with the following exceptions:")
                    for e in self._Downloader.get_errors():
                        print(unicode(e))

                    try:
                        self._Downloader.stop()
                    except:
                        pass

                    self._Screen._MsgBox.SetText("DownloadFailed")
                    self._Screen._MsgBox.Draw()
                    self._Screen.SwapAndShow()
                    return False
            else:
                self._Value = self._Downloader.get_progress()

                filename = os.path.basename(self._Downloader.get_dest())
                self._FileNameLabel.SetText(filename)

                downloaded = self._Downloader.progress["downloaded"]
                total = self._Downloader.progress["total"]

                downloaded = downloaded / 1000.0 / 1000.0
                total = total / 1000.0 / 1000.0

                self._SizeLabel.SetText("%.2f" % downloaded + "/" +
                                        "%.2f" % total + "Mb")

                print("Progress: %d%%" % (self._Value))
                self._Screen.Draw()
                self._Screen.SwapAndShow()
                return True
        else:
            return False

    def StartDownload(self, url, dst_dir):
        if is_wifi_connected_now() == False:
            return

        if validators.url(url) and os.path.isdir(dst_dir):
            self._URL = url
            self._DST_DIR = dst_dir
        else:
            self._Screen._MsgBox.SetText("Invaid")
            self._Screen._MsgBox.Draw()
            self._Screen.SwapAndShow()
            print("url or dst dir error")
            return

        self._Downloader = Download(url, dst_dir, None)
        self._Downloader.start()

        self._DownloaderTimer = gobject.timeout_add(
            100, self.GObjectUpdateProcessInterval)

    def KeyDown(self, event):
        if IsKeyMenuOrB(event.key):
            gobject.source_remove(self._DownloaderTimer)
            self._DownloaderTimer = -1

            if self._Downloader != None:
                try:
                    self._Downloader.stop()
                except:
                    print("user canceled ")

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

    def Draw(self):
        self.ClearCanvas()

        if is_wifi_connected_now() == False:
            self._Icons["needwifi_bg"].NewCoord(self._Width / 2,
                                                self._Height / 2)
            self._Icons["needwifi_bg"].Draw()
            return

        self._Icons["bg"].NewCoord(self._Width / 2, self._Height / 2 - 20)
        self._Icons["bg"].Draw()

        percent = self._Value
        if percent < 10:
            percent = 10

        rect_ = midRect(self._Width / 2, self._Height / 2 + 33, 170, 17, Width,
                        Height)
        aa_round_rect(self._CanvasHWND, rect_,
                      MySkinManager.GiveColor('TitleBg'), 5, 0,
                      MySkinManager.GiveColor('TitleBg'))

        rect2 = midRect(self._Width / 2, self._Height / 2 + 33,
                        int(170 * (percent / 100.0)), 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'))

        rect3 = midRect(self._Width / 2, self._Height / 2 + 53,
                        self._FileNameLabel._Width,
                        self._FileNameLabel._Height, Width, Height)

        rect4 = midRect(self._Width / 2, self._Height / 2 + 70,
                        self._SizeLabel._Width, self._SizeLabel._Height, Width,
                        Height)

        self._FileNameLabel.NewCoord(rect3.left, rect3.top)
        self._SizeLabel.NewCoord(rect4.left, rect4.top)

        self._FileNameLabel.Draw()
        self._SizeLabel.Draw()
示例#15
0
class MPDSpectrumPage(Page):

    _Icons = {}
    _Selector = None
    _FootMsg = ["Nav", "", "", "Back", ""]
    _MyList = []
    _ListFont = fonts["veramono12"]
    _SongFont = fonts["notosanscjk12"]
    _PIFI = None
    _FIFO = None
    _Color = pygame.Color(126, 206, 244)
    _GobjectIntervalId = -1
    _Queue = None
    _KeepReading = True
    _ReadingThread = None

    _BGpng = None
    _BGwidth = 320
    _BGheight = 200

    _SheepHead = None
    _SheepHeadW = 69
    _SheepHeadH = 66

    _SheepBody = None
    _SheepBodyW = 105
    _SheepBodyH = 81

    _RollCanvas = None
    _RollW = 180
    _RollH = 18

    _freq_count = 0
    _head_dir = 0

    _Neighbor = None

    _bby = []
    _bbs = []
    _capYPositionArray = []
    _frames = 0
    read_retry = 0
    _queue_data = []
    _vis_values = []

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

    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
        self._RollCanvas = pygame.Surface((self._RollW, self._RollH))
        """
        self._BGpng = IconItem()
        self._BGpng._ImgSurf = MyIconPool._Icons["sheep_bg"]
        self._BGpng._MyType = ICON_TYPES["STAT"]
        self._BGpng._Parent = self
        self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
        
        self._SheepHead = IconItem()
        self._SheepHead._ImgSurf = MyIconPool._Icons["sheep_head"]
        self._SheepHead._MyType = ICON_TYPES["STAT"]
        self._SheepHead._Parent = self
        self._SheepHead.Adjust(0,0,self._SheepHeadW,self._SheepHeadH,0)

        self._SheepBody = IconItem()
        self._SheepBody._ImgSurf = MyIconPool._Icons["sheep_body"]
        self._SheepBody._MyType = ICON_TYPES["STAT"]
        self._SheepBody._Parent = self
        self._SheepBody.Adjust(0,0,self._SheepBodyW,self._SheepBodyH,0)
        """

        self._cwp_png = IconItem()
        self._cwp_png._ImgSurf = MyIconPool._Icons["tape"]
        self._cwp_png._MyType = ICON_TYPES["STAT"]
        self._cwp_png._Parent = self
        self._cwp_png.Adjust(0, 0, 79, 79, 0)

        self._song_title = Label()
        self._song_title.SetCanvasHWND(self._RollCanvas)
        self._song_title.Init("Untitled", self._SongFont, (255, 255, 255))

        self._title = Label()
        self._title.SetCanvasHWND(self._CanvasHWND)
        self._title.Init("Title:", self._ListFont, (255, 255, 255))

        self._time = Label()
        self._time.SetCanvasHWND(self._CanvasHWND)
        self._time.Init("Time:", self._ListFont, (255, 255, 255))

        self._time2 = Label()
        self._time2.SetCanvasHWND(self._CanvasHWND)
        self._time2.Init("00:00-00:00", self._ListFont, (255, 255, 255))

        self.Start()

    def Start(self):

        if self._Screen.CurPage() != self:
            return

        try:
            self._FIFO = os.open(self._PIFI._MPD_FIFO,
                                 os.O_RDONLY | os.O_NONBLOCK)

            t = Thread(target=self.GetSpectrum)
            t.daemon = True  # thread dies with the program
            t.start()
            self._ReadingThread = t

        except IOError:
            print("open %s failed" % self._PIFI._MPD_FIFO)
            self._FIFO = None
            return

    def GetSpectrum(self):
        while self._KeepReading and self._FIFO != None:
            raw_samples = self._PIFI.GetSpectrum(self._FIFO)
            if len(raw_samples) < 1:
                #print("sleeping... 0.01")
                time.sleep(0.01)
                self.read_retry += 1
                if self.read_retry > 20:
                    os.close(self._FIFO)
                    self._FIFO = os.open(self._PIFI._MPD_FIFO,
                                         os.O_RDONLY | os.O_NONBLOCK)
                    self.read_retry = 0

                self.Playing()

            else:
                self.read_retry = 0
                self._queue_data = raw_samples
                self.Playing()

    def Playing(self):

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

    def ClearCanvas(self):
        self._CanvasHWND.fill((0, 0, 0))

    def SgsSmooth(self):
        passes = 1
        points = 3
        origs = self._bby[:]
        for p in range(0, passes):
            pivot = int(points / 2.0)

            for i in range(0, pivot):
                self._bby[i] = origs[i]
                self._bby[len(origs) - i - 1] = origs[len(origs) - i - 1]

            smooth_constant = 1.0 / (2.0 * pivot + 1.0)
            for i in range(pivot, len(origs) - pivot):
                _sum = 0.0
                for j in range(0, (2 * pivot) + 1):
                    _sum += (smooth_constant *
                             origs[i + j - pivot]) + j - pivot

                self._bby[i] = _sum

            if p < (passes - 1):
                origs = self._bby[:]

    def OnLoadCb(self):
        if self._Neighbor != None:
            pass

        if self._KeepReading == False:
            self._KeepReading = True

        if self._FIFO == None:
            self.Start()

    def KeyDown(self, event):
        if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
            try:
                os.close(self._FIFO)
                self._FIFO = None

            except Exception, e:
                print(e)

            self._KeepReading = False
            self._ReadingThread.join()
            self._ReadingThread = None

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

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

        if event.key == CurKeys["Enter"]:
            pass
示例#16
0
    def Init(self, i, is_active):
        # Pick which strength measure to use based on what the daemon says
        # gap allocates more space to the first module
        if self._Parent._Daemon.GetSignalDisplayType() == 0:
            strenstr = 'quality'
            gap = 4  # Allow for 100%
        else:
            strenstr = 'strength'
            gap = 7  # -XX dbm = 7
        self._NetId = i
        # All of that network property stuff
        self._Stren = self._Parent._Daemon.FormatSignalForPrinting(
                str(self._Parent._Wireless.GetWirelessProperty(self._NetId, strenstr)))
        
        self._Essid = self._Parent._Wireless.GetWirelessProperty(self._NetId, 'essid')
        self._Bssid = self._Parent._Wireless.GetWirelessProperty(self._NetId, 'bssid')

        if self._Parent._Wireless.GetWirelessProperty(self._NetId, 'encryption'):
            self._Encrypt = \
                self._Parent._Wireless.GetWirelessProperty(self._NetId, 'encryption_method')
        else:
            self._Encrypt = 'Unsecured'

        self._Mode = \
            self._Parent._Wireless.GetWirelessProperty(self._NetId, 'mode')  # Master, Ad-Hoc
        self._Channel = self._Parent._Wireless.GetWirelessProperty(self._NetId, 'channel')
        theString = '  %-*s %25s %9s %17s %6s %4s' % \
            (gap, self._Stren, self._Essid, self._Encrypt, self._Bssid, self._Mode,
                self._Channel)
        
        if is_active:
            theString = ">> "+theString[1:]
            self.SetActive(is_active)
        


        essid_label = Label()
        essid_label._PosX = 36
        #essid_label._PosY = self._PosY +  (self._Height - self._FontObj.render(self._Essid,True,(83,83,83)).get_height())/2
        essid_label._CanvasHWND = self._Parent._CanvasHWND

        if len(self._Essid) > 19:
            essid_ = self._Essid[:20]
        else:
            essid_ = self._Essid
        
        essid_label.Init(essid_,self._FontObj)
        self._Labels["essid"] = essid_label

        stren_label = Label()
        #stren_label._PosY = self._PosY +  (self._Height - self._FontObj.render(self._Stren,True,(83,83,83)).get_height())/2
        stren_label._CanvasHWND = self._Parent._CanvasHWND

        stren_label.Init(self._Stren,self._FontObj)
        stren_label._PosX = self._Width - 23 - stren_label.Width() - 2
        self._Labels["stren"] = stren_label
        

        lock_icon = NetItemIcon()
        lock_icon._ImgSurf = MyIconPool._Icons["lock"]
        lock_icon._CanvasHWND = self._Parent._CanvasHWND
        lock_icon._Parent = self
        self._Icons["lock"] = lock_icon
        
        done_icon = NetItemIcon()
        done_icon._ImgSurf = MyIconPool._Icons["done"]
        done_icon._CanvasHWND = self._Parent._CanvasHWND
        done_icon._Parent = self
        
        self._Icons["done"] = done_icon


        ## reuse the resource from TitleBar
        nimt = NetItemMultiIcon()
        nimt._ImgSurf = self._Parent._Screen._TitleBar._Icons["wifistatus"]._ImgSurf
        nimt._CanvasHWND = self._Parent._CanvasHWND
        nimt._Parent = self
        self._Icons["wifistatus"] = nimt
示例#17
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'))
示例#18
0
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
示例#19
0
class LoadHousePage(Page):
    _FootMsg = ["Nav.", "", "", "Back", "Cancel"]
    _Value = 0
    _URL = None
    _ListFontObj = MyLangManager.TrFont("varela18")
    _URLColor = MySkinManager.GiveColor('URL')
    _TextColor = MySkinManager.GiveColor('Text')
    _Caller = None
    _img = None
    _Downloader = None
    _DownloaderTimer = -1

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

    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
        self._LoadingLabel = Label()
        self._LoadingLabel.SetCanvasHWND(self._CanvasHWND)
        self._LoadingLabel.Init("Loading", self._ListFontObj)
        self._LoadingLabel.SetColor(self._TextColor)

    def OnLoadCb(self):
        if self._URL is None:
            return
        self._img = None
        self.ClearCanvas()
        self._Screen.Draw()
        self._Screen.SwapAndShow()

        filename = self._URL.split("/")[-1].strip()
        local_dir = self._URL.split("raw.githubusercontent.com")

        if len(local_dir) > 1:
            menu_file = local_dir[1]
            local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),
                                                      menu_file)

            if FileExists(local_menu_file):
                #load json
                with open(local_menu_file) as json_file:
                    try:
                        local_menu_json = json.load(json_file)
                        self._Caller._MyStack.Push(local_menu_json["list"])
                    except:
                        pass

                    self.Leave()

            else:
                self._Downloader = Download(self._URL, "/tmp", None)
                self._Downloader.start()
                self._DownloaderTimer = gobject.timeout_add(
                    400, self.GObjectUpdateProcessInterval)

    def GObjectUpdateProcessInterval(self):
        ret = True
        if self._Screen.CurPage() == self:
            if self._Downloader._stop == True:
                ret = False

            dst_filename = self._Downloader.get_dest()
            if self._Downloader.isFinished():
                if self._Downloader.isSuccessful():
                    filename = self._URL.split("/")[-1].strip()
                    local_dir = self._URL.split("raw.githubusercontent.com")
                    menu_file = local_dir[1]
                    local_menu_file = "%s/aria2download%s" % (
                        os.path.expanduser('~'), menu_file)

                    dl_file = os.path.join("/tmp", filename)
                    if not os.path.exists(os.path.dirname(local_menu_file)):
                        os.makedirs(os.path.dirname(local_menu_file))

                    copyfile(dl_file, local_menu_file)
                    with open(local_menu_file) as json_file:
                        try:
                            local_menu_json = json.load(json_file)
                            self._Caller._MyStack.Push(local_menu_json["list"])
                        except:
                            pass

                    ret = False

                    self.Leave()
                else:
                    self._Screen._MsgBox.SetText("Fetch house failed")
                    self._Screen._MsgBox.Draw()
                    self._Screen.SwapAndShow()
                    ret = False
            return ret
        else:
            return False

    def Leave(self):
        if self._DownloaderTimer != -1:
            gobject.source_remove(self._DownloaderTimer)
        self._DownloaderTimer = -1

        if self._Downloader != None:
            try:
                self._Downloader.stop()
            except:
                print("user canceled ")

        self.ReturnToUpLevelPage()
        self._Screen.Draw()
        self._Screen.SwapAndShow()
        self._URL = None

    def KeyDown(self, event):
        if IsKeyMenuOrB(event.key):
            self.Leave()

    def Draw(self):
        self.ClearCanvas()
        self._LoadingLabel.NewCoord((Width - self._LoadingLabel._Width) / 2,
                                    (Height - 44) / 2)
        self._LoadingLabel.Draw()

        if self._img is not None:
            self._CanvasHWND.blit(
                self._img,
                midRect(Width / 2, (Height - 44) / 2,
                        pygame.Surface.get_width(self._img),
                        pygame.Surface.get_height(self._img), Width,
                        Height - 44))
示例#20
0
class BSlider(Slider):

    
    OnChangeCB = None
    _Parent     = None
    _Icons      = {}
    
    def __init__(self):
        Slider.__init__(self)
        self._Icons = {}
    def Init(self):
        self._Width = self._Parent._Width
        self._Height = self._Parent._Height
        
        self._BrightnessLabel = Label()
        self._BrightnessLabel.SetCanvasHWND(self._CanvasHWND)
        self._BrightnessLabel.Init("BRIGHT",MySkinManager.GiveFont("EurostileBold13"))
        self._BrightnessLabel.SetColor(MySkinManager.GiveColor('Text'))
        

    def SetValue(self,brt):
        self._Value = brt
        
    def Further(self):
        self._Value+=1
        if self._Value > 9:
            self._Value = 9
            
        if self.OnChangeCB != None:
            if callable(self.OnChangeCB):
                self.OnChangeCB(self._Value)
                    
    def StepBack(self):
        self._Value-=1

        if self._Value < 1:
            self._Value = 1

        if self.OnChangeCB != None:
            if callable(self.OnChangeCB):
                self.OnChangeCB(self._Value)
    
    def Draw(self):
        start_x = 82
        start_y = self._Parent._Screen._Height/2-5
        height = 30
        width = 4
        padding = 15
        seg = self._Value-1

        for i in range(0,9):
            rect = pygame.Rect(start_x+i*(width+padding),start_y,width,height)
            if i > seg:
                pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),rect, 1)
                #aa_round_rect(self._CanvasHWND,rect, MySkinManager.GiveColor('Text'),1,1, MySkinManager.GiveColor('White'))
            else:
                pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),rect, 0)   
                #aa_round_rect(self._CanvasHWND,rect, MySkinManager.GiveColor('Text'),1,0, MySkinManager.GiveColor('White'))
        
        self._BrightnessLabel.NewCoord(118,self._Parent._Screen._Height/2-30)
        self._BrightnessLabel.Draw(True)
        
        minus_box_rect = pygame.Rect(start_x- (4+6)*4,start_y,6*4,30)
        pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),minus_box_rect, 0) 
        
        minus_rect     = pygame.Rect(start_x-8*4,start_y+14,2*4,2)
        pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('White'),minus_rect, 0) 
        
        plus_box_rect = pygame.Rect(start_x + 39*4 +4*4,start_y,6*4,30)
        pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),plus_box_rect, 0) 
        
        cross1_rect     = pygame.Rect(start_x+39*4+4*4+2*4,start_y+14,2*4,2)
        pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('White'),cross1_rect, 0) 
        cross2_rect     = pygame.Rect(start_x+39*4+4*4+2*4+3,start_y+14-3,2,2*4)
        pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('White'),cross2_rect, 0) 
示例#21
0
class StoragePage(Page):

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

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

    _TextColor = MySkinManager.GiveColor('Text')
    _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._GBLabel = Label()
        self._GBLabel.SetCanvasHWND(self._CanvasHWND)
        self._GBLabel.Init(
            self._GBmsg % (self._DskUsg[1] - self._DskUsg[0], self._DskUsg[1]),
            MySkinManager.GiveFont("varela11"))
        self._GBLabel.SetColor(self._TextColor)

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

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

        self._PctLabel.Init("%d%%" % int(usage_percent),
                            MySkinManager.GiveFont("EurostileBold30"))
        self._PctLabel.SetColor(self._TextColor)

        self._FreeLabel = Label()
        self._FreeLabel.SetCanvasHWND(self._CanvasHWND)
        self._FreeLabel.Init("FREE", MySkinManager.GiveFont("varela12"))
        self._FreeLabel.SetColor(self._PctLabel._Color)

    def OnLoadCb(self):
        pass

    def Draw(self):
        self.ClearCanvas()

        self._PctLabel.NewCoord(32, 102 - 33)
        self._PctLabel.Draw()

        self._FreeLabel.NewCoord(33, 130 - 25)
        self._FreeLabel.Draw()

        self._GBLabel.NewCoord(145, 103 - 29)
        self._GBLabel.Draw()

        #bgcolor = (238,238,238), fgcolor = (126,206,244)

        usage_percent = (self._DskUsg[0] / self._DskUsg[1])
        if usage_percent < 0.1:
            usage_percent = 0.1

        rect_ = pygame.Rect(144, 118 - 25, 283 - 144, 139 - 117)

        pygame.draw.rect(self._CanvasHWND, MySkinManager.GiveColor('Text'),
                         rect_, 1)

        rect2 = pygame.Rect(144, 118 - 25,
                            int((283 - 144) * (1.0 - usage_percent)),
                            139 - 117)

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

        pygame.draw.rect(self._CanvasHWND, MySkinManager.GiveColor('Text'),
                         rect2, 0)

        sep_rect = pygame.Rect(129, 99 - 25, 2, 42)

        pygame.draw.rect(self._CanvasHWND, MySkinManager.GiveColor('Text'),
                         sep_rect, 0)

        ##4 cross
        self.DrawCross(10, 10)
        self.DrawCross(self._Screen._Width - 20, 10)
        self.DrawCross(10, self._Screen._Height - 20)
        self.DrawCross(self._Screen._Width - 20, self._Screen._Height - 20)