예제 #1
0
    def drawBackground(self):
        self._readThemeInfos(self.themeName)

        # Reset background (delete images)
        for imgRef in self.refBgndImages:
            karamba.deleteImage(Applet.widget, imgRef)
        self.refBgndImages = []
        # Header
        ref = karamba.createBackgroundImage(Applet.widget, 0, 0,
                                            self.themeHeaderImg)
        self.themeHeaderWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)
        # Header's text
        self.refHeaderTitle = karamba.createRichText(Applet.widget,
                                                     self.themeHeaderTxtTitle,
                                                     0)
        karamba.moveRichText(Applet.widget, self.refHeaderTitle,
                             self.themeHeaderTxtTitleXY[0],
                             self.themeHeaderTxtTitleXY[1])
        karamba.setRichTextWidth(Applet.widget, self.refHeaderTitle,
                                 self.themeHeaderTxtTitleWH[0])
        self.refHeaderWhen = karamba.createRichText(Applet.widget,
                                                    self.themeHeaderTxtWhen, 0)
        karamba.moveRichText(Applet.widget, self.refHeaderWhen,
                             self.themeHeaderTxtWhenXY[0],
                             self.themeHeaderTxtWhenXY[1])
        karamba.setRichTextWidth(Applet.widget, self.refHeaderWhen,
                                 self.themeHeaderTxtWhenWH[0])
        #---
        # Applet must display at least 1 line
        posY = self.themeHeaderWH[1]
        ref = karamba.createBackgroundImage(Applet.widget, 0, posY,
                                            self.themeBodyImg)
        self.themeBodyWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)
        # Display other lines...
        for i in range(1, self.themeLines):
            posY += self.themeBodyWH[1]
            ref = karamba.createBackgroundImage(Applet.widget, 0, posY,
                                                self.themeBodyImg)
            self.refBgndImages.append(ref)
        # Footer
        posY += self.themeBodyWH[1]
        ref = karamba.createBackgroundImage(Applet.widget, 0, posY,
                                            self.themeFooterImg)
        self.themeFooterWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)

        # Change widget size
        Applet.widgetSize = (Applet.widgetSize[0],
                             posY + self.themeFooterWH[1])
        karamba.resizeWidget(Applet.widget, Applet.widgetSize[0],
                             Applet.widgetSize[1])
        karamba.redrawWidgetBackground(Applet.widget)
        karamba.redrawWidget(Applet.widget)
예제 #2
0
 def show(self):
     # Image
     self.refSplash = karamba.createImage(Applet.widget,
                                          self.splashImageXY[0],
                                          self.splashImageXY[1],
                                          self.splashImage)
     self.splashImageWH = karamba.getImageSize(Applet.widget,
                                               self.refSplash)
     xPos = (Applet.widgetSize[0] - self.splashImageWH[0]) / 2
     self.splashImageXY = (xPos, self.splashImageXY[1])
     karamba.moveImage(Applet.widget, self.refSplash,
                       self.splashImageXY[0], self.splashImageXY[1])
     # Text
     yPos = (self.splashImageXY[1] + self.splashImageWH[1]) + 10
     self.splashTextXY = (0, yPos)
     self.splashTextWH = (Applet.widgetSize[0], 14)
     self.refSplashText = karamba.createText(Applet.widget,
                                             self.splashTextXY[0],
                                             self.splashTextXY[1],
                                             self.splashTextWH[0],
                                             self.splashTextWH[1], "")
     karamba.setTextAlign(Applet.widget, self.refSplashText, "CENTER")
     karamba.changeTextColor(Applet.widget, self.refSplashText, 0xFF,
                             0xFF, 0xFF)
     #
     for i in range(100):
         karamba.redrawWidget(Applet.widget)
예제 #3
0
파일: Applet.py 프로젝트: gilcn/nextshows
    def drawBackground(self):
        self._readThemeInfos(self.themeName)

        # Reset background (delete images)
        for imgRef in self.refBgndImages:
            karamba.deleteImage(Applet.widget, imgRef)
        self.refBgndImages = []
        # Header
        ref = karamba.createBackgroundImage(Applet.widget, 0, 0, self.themeHeaderImg)
        self.themeHeaderWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)
        # Header's text
        self.refHeaderTitle = karamba.createRichText(Applet.widget, self.themeHeaderTxtTitle, 0)
        karamba.moveRichText(Applet.widget, self.refHeaderTitle, self.themeHeaderTxtTitleXY[0], self.themeHeaderTxtTitleXY[1])
        karamba.setRichTextWidth(Applet.widget, self.refHeaderTitle, self.themeHeaderTxtTitleWH[0])
        self.refHeaderWhen  = karamba.createRichText(Applet.widget, self.themeHeaderTxtWhen, 0)
        karamba.moveRichText(Applet.widget, self.refHeaderWhen, self.themeHeaderTxtWhenXY[0], self.themeHeaderTxtWhenXY[1])
        karamba.setRichTextWidth(Applet.widget, self.refHeaderWhen, self.themeHeaderTxtWhenWH[0])
        #---
        # Applet must display at least 1 line
        posY = self.themeHeaderWH[1]
        ref  = karamba.createBackgroundImage(Applet.widget, 0, posY, self.themeBodyImg)
        self.themeBodyWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)
        # Display other lines...
        for i in range(1, self.themeLines):
            posY += self.themeBodyWH[1]
            ref = karamba.createBackgroundImage(Applet.widget, 0, posY, self.themeBodyImg)
            self.refBgndImages.append(ref)
        # Footer
        posY += self.themeBodyWH[1]
        ref = karamba.createBackgroundImage(Applet.widget, 0, posY, self.themeFooterImg)
        self.themeFooterWH = karamba.getImageSize(Applet.widget, ref)
        self.refBgndImages.append(ref)

        # Change widget size
        Applet.widgetSize = ( Applet.widgetSize[0], posY + self.themeFooterWH[1] )
        karamba.resizeWidget( Applet.widget, Applet.widgetSize[0], Applet.widgetSize[1] )
        karamba.redrawWidgetBackground(Applet.widget)
        karamba.redrawWidget(Applet.widget)
예제 #4
0
파일: Applet.py 프로젝트: gilcn/nextshows
 def show(self):
     # Image
     self.refSplash     = karamba.createImage(Applet.widget, self.splashImageXY[0], self.splashImageXY[1], self.splashImage)
     self.splashImageWH = karamba.getImageSize(Applet.widget, self.refSplash)
     xPos = ( Applet.widgetSize[0] - self.splashImageWH[0] ) / 2
     self.splashImageXY = ( xPos, self.splashImageXY[1] )
     karamba.moveImage( Applet.widget, self.refSplash, self.splashImageXY[0], self.splashImageXY[1] )
     # Text
     yPos = ( self.splashImageXY[1] + self.splashImageWH[1] ) + 10
     self.splashTextXY  = ( 0, yPos )
     self.splashTextWH  = ( Applet.widgetSize[0], 14 )
     self.refSplashText = karamba.createText( Applet.widget,
                                              self.splashTextXY[0],
                                              self.splashTextXY[1],
                                              self.splashTextWH[0],
                                              self.splashTextWH[1],
                                              "" )
     karamba.setTextAlign(Applet.widget, self.refSplashText, "CENTER")
     karamba.changeTextColor(Applet.widget, self.refSplashText, 0xFF, 0xFF, 0xFF)
     #
     for i in range(100): karamba.redrawWidget(Applet.widget)
예제 #5
0
파일: image.py 프로젝트: Fat-Zer/tdeutils
def widgetUpdated(widget):
    global images, c
    
    b = c%2

    # Create & delete
    if(images[0]):
      karamba.deleteImage(widget, images[0])
      images[0] = 0
    else:
      images[0] = karamba.createImage(widget, 0, 20, "flag.png")
			
    # Hide & Show
    if(b):
      karamba.hideImage(widget, images[1])
    else:
      karamba.showImage(widget, images[1])
    
    # size & resize
    size = karamba.getImageSize(widget, images[1])
    print "getImageSize: " + str(size)
    print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1]))
    print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1]))
    # Auto size
    #size = ((b * 200) + 200, size[1])    
    #karamba.resizeImage(widget, images[1], size[0], size[1])
    
    # pos & move
    pos = karamba.getImagePos(widget, images[2])
    print "getImagePos: " + str(pos)
    pos = (b * 200, pos[1])    
    karamba.moveImage(widget, images[2], pos[0], pos[1])
    
    # Sensor
    sensor = karamba.getImageSensor(widget, images[3])
    print "getSensor: " + str(sensor)
    if(b):
      karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM  PROGRAM="/tmp/test1.sh"')
    else:
      karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM  PROGRAM="/tmp/test2.sh"')
      
    # Value
    v = karamba.getImagePath(widget, images[4])
    print "getImagePath: ", v
    if(b):
      v = 'flag.png'
    else:
      v = 'flag2.png'
    karamba.setImagePath(widget, images[4], v)
    
    if((c % 10) == 0):
      karamba.removeImageEffects(widget, images[5])
      karamba.removeImageEffects(widget, images[6])
      karamba.removeImageEffects(widget, images[7])
    else:
      karamba.changeImageIntensity(widget, images[5], (float(c%10) / 5 - 1.0))
      karamba.changeImageChannelIntensity(widget, images[6], (float(c%10) / 5 - 1.0), 'blue')
      karamba.changeImageToGray(widget, images[7], 0)

    if((c % 9) == 0):
      karamba.removeImageTransformations(widget, images[8])
      karamba.removeImageTransformations(widget, images[9])
      karamba.removeImageTransformations(widget, images[10])
    else:
      karamba.rotateImage(widget, images[8], (c%9)*20 + 45)
      karamba.resizeImage(widget, images[9], 50 + (c%5)*10, size[1])
      karamba.resizeImageSmooth(widget, images[10], 50 + (c%5)*10, size[1])
      
    if((c % 10) == 0):
      karamba.addImageTooltip(widget, images[11], str(c))
      
    if((c % 20) == 0):
      if(images[12]):
        karamba.deleteImage(widget, images[12])
        images[12] = 0
      else:
        images[12] = karamba.createBackgroundImage(widget, 0, 340, "flag.png")
    
    if(images[13]):
      karamba.deleteImage(widget, images[13])
      images[13] = 0
    else:
      tlist = karamba.getTaskList(widget)
      images[13] = karamba.createTaskIcon(widget, 50, 340, tlist[c % len(tlist)])
      
    c += 1
예제 #6
0
def widgetUpdated(widget):
    global images, c

    b = c % 2

    # Create & delete
    if (images[0]):
        karamba.deleteImage(widget, images[0])
        images[0] = 0
    else:
        images[0] = karamba.createImage(widget, 0, 20, "flag.png")

    # Hide & Show
    if (b):
        karamba.hideImage(widget, images[1])
    else:
        karamba.showImage(widget, images[1])

    # size & resize
    size = karamba.getImageSize(widget, images[1])
    print "getImageSize: " + str(size)
    print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1]))
    print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1]))
    # Auto size
    #size = ((b * 200) + 200, size[1])
    #karamba.resizeImage(widget, images[1], size[0], size[1])

    # pos & move
    pos = karamba.getImagePos(widget, images[2])
    print "getImagePos: " + str(pos)
    pos = (b * 200, pos[1])
    karamba.moveImage(widget, images[2], pos[0], pos[1])

    # Sensor
    sensor = karamba.getImageSensor(widget, images[3])
    print "getSensor: " + str(sensor)
    if (b):
        karamba.setImageSensor(widget, images[3],
                               'SENSOR=PROGRAM  PROGRAM="/tmp/test1.sh"')
    else:
        karamba.setImageSensor(widget, images[3],
                               'SENSOR=PROGRAM  PROGRAM="/tmp/test2.sh"')

    # Value
    v = karamba.getImagePath(widget, images[4])
    print "getImagePath: ", v
    if (b):
        v = 'flag.png'
    else:
        v = 'flag2.png'
    karamba.setImagePath(widget, images[4], v)

    if ((c % 10) == 0):
        karamba.removeImageEffects(widget, images[5])
        karamba.removeImageEffects(widget, images[6])
        karamba.removeImageEffects(widget, images[7])
    else:
        karamba.changeImageIntensity(widget, images[5],
                                     (float(c % 10) / 5 - 1.0))
        karamba.changeImageChannelIntensity(widget, images[6],
                                            (float(c % 10) / 5 - 1.0), 'blue')
        karamba.changeImageToGray(widget, images[7], 0)

    if ((c % 9) == 0):
        karamba.removeImageTransformations(widget, images[8])
        karamba.removeImageTransformations(widget, images[9])
        karamba.removeImageTransformations(widget, images[10])
    else:
        karamba.rotateImage(widget, images[8], (c % 9) * 20 + 45)
        karamba.resizeImage(widget, images[9], 50 + (c % 5) * 10, size[1])
        karamba.resizeImageSmooth(widget, images[10], 50 + (c % 5) * 10,
                                  size[1])

    if ((c % 10) == 0):
        karamba.addImageTooltip(widget, images[11], str(c))

    if ((c % 20) == 0):
        if (images[12]):
            karamba.deleteImage(widget, images[12])
            images[12] = 0
        else:
            images[12] = karamba.createBackgroundImage(widget, 0, 340,
                                                       "flag.png")

    if (images[13]):
        karamba.deleteImage(widget, images[13])
        images[13] = 0
    else:
        tlist = karamba.getTaskList(widget)
        images[13] = karamba.createTaskIcon(widget, 50, 340,
                                            tlist[c % len(tlist)])

    c += 1