Esempio n. 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)
Esempio n. 2
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)
Esempio n. 3
0
 def hide(self):
     karamba.deleteText(Applet.widget, self.refSplashText)
     karamba.deleteImage(Applet.widget, self.refSplash)
     for i in range(100): karamba.redrawWidget(Applet.widget)
Esempio n. 4
0
 def hide(self):
     karamba.deleteText(Applet.widget, self.refSplashText)
     karamba.deleteImage(Applet.widget, self.refSplash)
     for i in range(100):
         karamba.redrawWidget(Applet.widget)
Esempio n. 5
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
Esempio n. 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