Ejemplo n.º 1
0
    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

        li = Label()
        li.SetCanvasHWND(self._CanvasHWND)
        li.Init(self._ConfirmText, self._ListFont)

        li._PosX = (self._Width - li._Width) / 2
        li._PosY = (self._Height - li._Height) / 2

        self._BGPosX = li._PosX - 10
        self._BGPosY = li._PosY - 10
        self._BGWidth = li._Width + 20
        self._BGHeight = li._Height + 20

        self._MyList.append(li)
    def SetSmallText(self, text):

        l = Label()
        l._PosX = 40
        l.SetCanvasHWND(self._Parent._CanvasHWND)
        l.Init(text, self._Fonts["small"])
        self._Labels["Small"] = l
    def Init(self, text):

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

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

        l.Init(text, self._Fonts["normal"])
        self._Labels["Text"] = l
Ejemplo n.º 4
0
class IconItem(Widget):
    _ImageName = ""
    _ImgSurf = None
    _Parent = None
    _Index = 0
    _MyType = ICON_TYPES["EXE"]
    _CmdPath = ""
    _LinkPage = None
    _Label = None
    _Align = ALIGN["VCenter"]  # set for the Icon Image and Text Label

    def __init__(self):
        self._ImgSurf = None

    def Init(self, x, y, w, h, at):  # the Surface is assigned in Screen
        self._PosX = x
        self._PosY = y
        self._Width = w
        self._Height = h
        self._AnimationTime = at

    def SetLableColor(self, color):
        self._Label.SetColor(color)

    def AddLabel(self, text, fontobj):
        if self._Label == None:
            self._Label = Label()
            self._Label.Init(text, fontobj)
        else:
            #just replace the text
            self._Label._Init(text, fontobj)

    def Adjust(self, x, y, w, h, at):  # the Surface is assigned in Screen
        self.Init(x, y, w, h, at)

        if self._Label != None:
            self._Label.SetCanvasHWND(self._Parent._CanvasHWND)

        self.CreateImageSurf()
        self.AdjustLinkPage()

    def AdjustLinkPage(self):
        if self._MyType == ICON_TYPES["DIR"] and self._LinkPage != None:
            self._LinkPage._Index = 0
            self._LinkPage._Align = ALIGN["SLeft"]
            self._LinkPage._IconNumbers = len(self._LinkPage._Icons)
            self._LinkPage._Screen = self._Parent._Screen
            self._LinkPage._CanvasHWND = self._Parent._Screen._CanvasHWND

            self._LinkPage._FootMsg = ["Nav", "", "", "Back",
                                       "Enter"]  ## Default Page Foot info

            if self._LinkPage._Align == ALIGN["HLeft"]:
                self._LinkPage.AdjustHLeftAlign()
            elif self._LinkPage._Align == ALIGN["SLeft"]:
                self._LinkPage.AdjustSAutoLeftAlign()
                if self._LinkPage._IconNumbers > 1:
                    self._LinkPage._PsIndex = 1
                    self._LinkPage._IconIndex = self._LinkPage._PsIndex

    def CreateImageSurf(self):

        if self._ImgSurf == None and self._ImageName != "":
            #            print(self._ImageName)
            self._ImgSurf = pygame.image.load(self._ImageName).convert_alpha()
            #if self._ImgSurf.get_width() > icon_width or self._ImgSurf.get_height() > icon_height:
            #    self._ImgSurf = pygame.transform.scale(self._ImgSurf,(icon_width,icon_height))

    def ChangeImgSurfColor(self, color):
        color_surface(self._ImgSurf, color)

    def Clear(self):
        pass

    def DrawTopLeft(self):
        if self._Align == ALIGN["VCenter"]:  #default
            if self._Label != None:
                self._Label._PosX = self._PosX - self._Label._Width / 2 + self._Parent._PosX
                self._Label._PosY = self._PosY + self._Height / 2 + 6 + self._Parent._PosY

        elif self._Align == ALIGN["HLeft"]:
            if self._Label != None:
                self._Label._PosX = self._PosX + self._Width / 2 + 3 + self._Parent._PosX
                self._Label._PosY = self._PosY - self._Label._Height / 2 + self._Parent._PosY

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

        if self._ImgSurf != None:
            self._Parent._CanvasHWND.blit(
                self._ImgSurf,
                pygame.Rect(self._PosX + self._Parent._PosX,
                            self._PosY + self._Parent._PosY, self._Width,
                            self._Height))

    def Draw(self):
        if self._Align == ALIGN["VCenter"]:  #default
            if self._Label != None:
                self._Label._PosX = self._PosX - self._Label._Width / 2 + self._Parent._PosX
                self._Label._PosY = self._PosY + self._Height / 2 + 6 + self._Parent._PosY

        elif self._Align == ALIGN["HLeft"]:
            if self._Label != None:
                self._Label._PosX = self._PosX + self._Width / 2 + 3 + self._Parent._PosX
                self._Label._PosY = self._PosY - self._Label._Height / 2 + self._Parent._PosY

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

        if self._ImgSurf != None:
            self._Parent._CanvasHWND.blit(
                self._ImgSurf,
                midRect(self._PosX + self._Parent._PosX,
                        self._PosY + self._Parent._PosY, self._Width,
                        self._Height, Width, Height))
Ejemplo n.º 5
0
class CounterScreen(FullScreen):

    _CounterFont = fonts["varela120"]
    _TextFont1    = fonts["varela15"]
    _TextFont2    = fonts["varela12"]
    
    _TopLabel = None
    _BottomLabel = None
    _NumberLabel = None
    
    _BGColor = pygame.Color(0,0,0)
    _FGColor = pygame.Color(255,255,255)
    
    _Counting = False
    _Number = 10
    _GobjectIntervalId = -1

    _inter_counter = 0
    
    def GObjectInterval(self):

        self._inter_counter+=1

        if self._Number == 0:
            self._Counting = False    
            print("do the real shutdown")
            
            if config.CurKeySet != "PC":
                cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;"
                cmdpath += "sleep 3;"
                cmdpath += "sudo halt -p"
                pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))\
            
            return False
    
        if self._inter_counter >=2:
            self._Number -= 1
            if self._Number < 0:
                self._Number = 0
            print("sub Number %d " % self._Number)
            self._inter_counter = 0
            
            self.Draw()
            self.SwapAndShow()


        
        return self._Counting
    
    def StartCounter(self):
        if self._Counting == True:
            return

        self._Number = 10
        self._Counting = True
        
        self._GobjectIntervalId = gobject.timeout_add(500,self.GObjectInterval)
        
    def StopCounter(self):
        if self._Counting == False:
            return
        self._Counting = False
        self._Number = 10

        if self._GobjectIntervalId != -1:
            gobject.source_remove(self._GobjectIntervalId)
            self._GobjectIntervalId = -1
        
        return
                    
    def Init(self):
        self._CanvasHWND = pygame.Surface((self._Width,self._Height))
        self._TopLabel = Label()
        self._TopLabel.SetCanvasHWND(self._CanvasHWND)
        self._TopLabel.Init("System shutdown in", self._TextFont1, self._FGColor)
        
        self._BottomLabel = Label()
        self._BottomLabel.SetCanvasHWND(self._CanvasHWND)
        self._BottomLabel.Init("Press any key to stop countdown", self._TextFont2, self._FGColor)
        
        self._NumberLabel = Label()
        self._NumberLabel.SetCanvasHWND(self._CanvasHWND)
        self._NumberLabel.Init(str(self._Number), self._CounterFont, self._FGColor)
        
    def Draw(self):
        self._CanvasHWND.fill( self._BGColor )

        self._TopLabel.NewCoord(Width/2, 15)
        self._TopLabel.DrawCenter()
        
        self._BottomLabel.NewCoord(Width/2, Height-15)
        self._BottomLabel.DrawCenter()

        self._NumberLabel.NewCoord(Width/2,Height/2)
        self._NumberLabel.SetText(str(self._Number))
        self._NumberLabel.DrawCenter()