def initWidget(widget): global resX global numOfTasks global taskPanels global taskText global timeText karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png") numOfTasks = (resX - 198 - 149) / 121 timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time") karamba.changeTextColor(widget, timeText, 0, 0, 0) karamba.changeTextSize(widget, timeText, 9) for i in range(numOfTasks): taskPanels.append( karamba.createImage(widget, 198 + (121 * i), 3, "pics/task_new.png")) taskText.append( karamba.createText(widget, 198 + (121 * i) + 9, 9, 100, 20, "")) for text in taskText: karamba.changeTextSize(widget, text, 9) drawTaskbar(widget)
def __init__(self,widget,handimage,shadowimage,scale,pivot_x,pivot_y,center_x,center_y,shadowlevel): self.imgshadow=karamba.createImage(widget,0,0,shadowimage) self.imghand=karamba.createImage(widget,0,0,handimage) hw=karamba.getImageWidth(widget,self.imghand) hh=karamba.getImageHeight(widget,self.imghand) r1=math.sqrt((pivot_x*pivot_x)+(pivot_y*pivot_y)) r4=r1 a1=math.pi-math.asin(pivot_y/r1) a4=2.0*math.pi-a1 r2=math.sqrt((pivot_y*pivot_y)+((hw-pivot_x)*(hw-pivot_x))) r3=r2 a2=math.asin(pivot_y/r2) a3=-a2 self.a1=a1 self.a2=a2 self.a3=a3 self.a4=a4 self.r1=r1*scale self.r2=r2*scale self.r3=r3*scale self.r4=r4*scale self.center_x=center_x self.center_y=center_y self.shadowlevel=shadowlevel self.prev=0.0 #prevents rotating etc. if not required
def initWidget(widget): global itempointer, diff, clickScrollUp, clickScrollDown, update, browserCommand getHeise(heise_url[urlpointer]) createMenu(widget) y_pos = 23 z = 0 while z < lines: itempointer.insert(z ,karamba.createText(widget, 14, y_pos, theme_width-18, line_height, "")) setStyle(widget, itempointer[z], 1, 17) karamba.changeTextColor(widget, itempointer[z], r,g,b) y_pos = y_pos + 15 z = z + 1 karamba.changeTextColor(widget, fill[0], 54,227,123) # karamba.changeTextColor(widget, fill[0], 255,255,255) # Menuoption "browser" karamba.addMenuConfigOption(widget, "browser", "Change your browser") browserCommand = karamba.readConfigEntry(widget, "browser") or "konqueror" # Up clickScrollUp = karamba.createImage(widget, 0, 0, "up.png") karamba.moveImage(widget, clickScrollUp, 50, 2) karamba.attachClickArea(widget, clickScrollUp, "") #Down clickScrollDown = karamba.createImage(widget, 0, 0, "down.png") karamba.moveImage(widget, clickScrollDown, 22, 3) karamba.attachClickArea(widget, clickScrollDown, "") fillContent(widget, "refresh") update = 0 widgetUpdated(widget)
def initWidget(widget): global text global button text = karamba.createText(widget, 80, 35, 90, 30, status()) karamba.changeTextSize(widget, text, 16) button = karamba.createImage(widget, 60, 90, "imgs/read-request.png") karamba.attachClickArea(widget, button, "./launch-viewer.sh", "", "") button = karamba.createImage(widget, 140, 90, "imgs/tinyerp-icon.ico") karamba.attachClickArea(widget, button, "./launch-ktiny.sh", "", "")
def readConfigImages(widget, theme_cfg): #### Begin reading [background images] and [images] from the config file #### for image in theme_cfg.options("background images"): x, y, file = theme_cfg.get( "background images", image ).split(",", 2) karamba.createBackgroundImage(widget, int(x), int(y), file.strip()) for image in theme_cfg.options("images"): x, y, file = theme_cfg.get( "images", image ).split(",", 2) karamba.createImage(widget, int(x), int(y), file.strip())
def readConfigImages(widget, theme_cfg): #### Begin reading [background images] and [images] from the config file #### for image in theme_cfg.options("background images"): x, y, file = theme_cfg.get("background images", image).split(",", 2) karamba.createBackgroundImage(widget, int(x), int(y), file.strip()) for image in theme_cfg.options("images"): x, y, file = theme_cfg.get("images", image).split(",", 2) karamba.createImage(widget, int(x), int(y), file.strip())
def initWidget(widget): global sechand,minhand,houhand karamba.createImage(widget,0,0,"dial.png") #hand parameter: widget,hand image,shadow image,scale factor,x coord of pivot in hand image, same in y, x coord of pivot in background image, sam in y, offset for shadow # the scale factor shrinks the hand image (for anti-alias) so hands should be drawn larger than required # shadow image must be of the same size a hand image; make hand image a little larger as needed for blurring houhand=Hand(widget,"hhand.png","hhands.png",0.18,0.0,5.0,75,92,3) minhand=Hand(widget,"mhand.png","mhands.png",0.23,0.0,5.0,75,92,4) # sechand=Hand(widget,"shand.png","shands.png",0.27,15.0,5.0,75,92,4) # disable me if you don't want a sec hand karamba.createImage(widget,0,0,"cover.png") # the center should be coverd since the hands are 'dancing' a little
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)
def initWidget(widget): global resX global numOfTasks global taskPanels global taskText global timeText karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png") numOfTasks = (resX - 198 - 149) / 121 timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time") karamba.changeTextColor(widget, timeText, 0, 0, 0) karamba.changeTextSize(widget, timeText, 9) for i in range(numOfTasks): taskPanels.append(karamba.createImage(widget, 198 + (121 * i), 3, "pics/task_new.png")) taskText.append(karamba.createText(widget, 198 + (121 * i) + 9, 9, 100, 20, "")) for text in taskText: karamba.changeTextSize(widget, text, 9) drawTaskbar(widget)
def initWidget(widget): global richtext global penguin karamba.resizeWidget(widget, 360, 520) penguin = karamba.createImage( widget, 250, 150, karamba.getThemePath(widget) + "/penguin_executive.png") karamba.hideImage(widget, penguin) text = """ <h1>Richtext Example</h1> <p>A rich text object allows to display a string interpreted as rich text. To create a rich text object use the command:<br> <p align="center">karamba.createRichText(widget, text)</p> A simple subset of <a href="kfmclient openURL http://www.selfhtml.org"><font color="black"><i>HTML</i></font></a>-tags is used to encode the formatting commands.</p> <p><font size=+2>Some features:</font> <ul> <li>Numbered and unnumbered lists</li> <li>Inline Images <img src=\"""" + karamba.getThemePath( widget) + u"""info.png\"</li> <li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li> <li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li> <li>Links can also <a href="#trigger">trigger</a> actions in the script</li> <li><i>Various</i> <b>different</b> <u>caracter</u> <s>styles</s></li> <li><a href="kfmclient openURL http://www.unicode.org">Unicode</a>: \u03B6 \u03B3 \u03BB \u03A3 \u03A9 </li> <li>Simple Tables: <table bgcolor="darkgray" border="1" width="80%"> <tr><th colspan="3">Header</th></tr> <tr><td>Cell (1,1)</td><td>Cell (1,2)</td><td>Cell (1,3)</td><tr> <tr><td>Cell (2,1)</td><td>Cell (2,2)</td><td>Cell (2,3)</td><tr> </table></li> </ul> For a complete documentation of all supported tags look at: <a href="kfmclient openURL http://doc.trolltech.com/3.0/qstylesheet.html"> http://doc.trolltech.com/3.0/qstylesheet.html</a>. </p><br> """ richtext = karamba.createRichText(widget, text) karamba.moveRichText(widget, richtext, 10, 10) print "richText Size = ", karamba.getRichTextSize(widget, richtext) karamba.setRichTextWidth(widget, richtext, 345) #karamba.deleteRichText(widget, richtext) karamba.redrawWidget(widget)
def initWidget(widget): global richtext global penguin karamba.resizeWidget(widget, 360, 520) penguin = karamba.createImage(widget, 250, 150, karamba.getThemePath(widget) + "/penguin_executive.png") karamba.hideImage(widget, penguin) text = """ <h1>Richtext Example</h1> <p>A rich text object allows to display a string interpreted as rich text. To create a rich text object use the command:<br> <p align="center">karamba.createRichText(widget, text)</p> A simple subset of <a href="kfmclient openURL http://www.selfhtml.org"><font color="black"><i>HTML</i></font></a>-tags is used to encode the formatting commands.</p> <p><font size=+2>Some features:</font> <ul> <li>Numbered and unnumbered lists</li> <li>Inline Images <img src=\"""" + karamba.getThemePath(widget) + u"""info.png\"</li> <li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li> <li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li> <li>Links can also <a href="#trigger">trigger</a> actions in the script</li> <li><i>Various</i> <b>different</b> <u>caracter</u> <s>styles</s></li> <li><a href="kfmclient openURL http://www.unicode.org">Unicode</a>: \u03B6 \u03B3 \u03BB \u03A3 \u03A9 </li> <li>Simple Tables: <table bgcolor="darkgray" border="1" width="80%"> <tr><th colspan="3">Header</th></tr> <tr><td>Cell (1,1)</td><td>Cell (1,2)</td><td>Cell (1,3)</td><tr> <tr><td>Cell (2,1)</td><td>Cell (2,2)</td><td>Cell (2,3)</td><tr> </table></li> </ul> For a complete documentation of all supported tags look at: <a href="kfmclient openURL http://doc.trolltech.com/3.0/qstylesheet.html"> http://doc.trolltech.com/3.0/qstylesheet.html</a>. </p><br> """ richtext = karamba.createRichText(widget, text) karamba.moveRichText(widget, richtext, 10, 10) print "richText Size = ", karamba.getRichTextSize(widget, richtext) karamba.setRichTextWidth(widget, richtext, 345) #karamba.deleteRichText(widget, richtext) karamba.redrawWidget(widget)
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)
def widgetUpdated(widget): global init global linkePupille global rechtePupille global w_width global w_height global w_x global w_y global lx global ly global la global lb global lp_width global lp_height global rx global ry global ra global rb global rp_width global rp_height global x_old global y_old if init == 0: theme_path = karamba.getThemePath(widget) + "/" # read widget coordinates from eyes.theme # f = open(theme_path + "eyes.theme") # karamba_line = "" #while re.compile('KARAMBA').search(karamba_line) == None: # karamba_line = f.readline() #w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1)) #w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1)) #f.close() #karamba.createWidgetMask(widget, theme_path + "pics/mask.png") linkePupille = karamba.createImage(widget, 15, 30, theme_path + "pics/pupille.png") rechtePupille = karamba.createImage(widget, 100, 30, theme_path + "pics/pupille.png") init = 1 karamba.redrawWidget(widget) # query mouse-cursor position x, y = xcursor.position() #fp = os.popen("./xpos") #output = fp.read() #x, y = output.split() #print x, y if x != x_old or y != y_old: x_old, y_old = x, y # Get Widget Position w_x, w_y = karamba.getWidgetPosition(widget) # Calc left pupille xp, yp = pupille(int(x), int(y), lx, ly, la, lb, w_x, w_y) xp = xp - lp_width / 2 yp = yp - lp_height / 2 #print xp, yp karamba.moveImage(widget, linkePupille, xp, yp) # Calc right pupille xp, yp = pupille(int(x), int(y), rx, ry, ra, rb, w_x, w_y) xp = xp - rp_width / 2 yp = yp - rp_height / 2 #print xp, yp karamba.moveImage(widget, rechtePupille, xp, yp) karamba.redrawWidget(widget)
def widgetUpdated(widget): global init global linkePupille global rechtePupille global w_width global w_height global w_x global w_y global lx global ly global la global lb global lp_width global lp_height global rx global ry global ra global rb global rp_width global rp_height global x_old global y_old if init == 0: theme_path = karamba.getThemePath(widget) + "/" # read widget coordinates from eyes.theme # f = open(theme_path + "eyes.theme") # karamba_line = "" #while re.compile('KARAMBA').search(karamba_line) == None: # karamba_line = f.readline() #w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1)) #w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1)) #f.close() #karamba.createWidgetMask(widget, theme_path + "pics/mask.png") linkePupille = karamba.createImage(widget, 15, 30, theme_path + "pics/pupille.png") rechtePupille = karamba.createImage(widget, 100, 30, theme_path + "pics/pupille.png") init = 1 karamba.redrawWidget(widget) # query mouse-cursor position x, y = xcursor.position() #fp = os.popen("./xpos") #output = fp.read() #x, y = output.split() #print x, y if x != x_old or y != y_old: x_old, y_old = x, y # Get Widget Position w_x, w_y = karamba.getWidgetPosition(widget) # Calc left pupille xp, yp = pupille (int(x), int(y), lx, ly, la, lb, w_x, w_y) xp = xp - lp_width / 2 yp = yp - lp_height / 2 #print xp, yp karamba.moveImage(widget, linkePupille, xp, yp) # Calc right pupille xp, yp = pupille (int(x), int(y), rx, ry, ra, rb, w_x, w_y) xp = xp - rp_width / 2 yp = yp - rp_height / 2 #print xp, yp karamba.moveImage(widget, rechtePupille, xp, yp) karamba.redrawWidget(widget)
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
def showWeekImage(self, widget, update): if update == 0: self.k_weekImage = karamba.createImage(widget, self.xMark[self.getDayCoords(self.thisDay)[0]], 50, "images/weekmark.png") else: karamba.moveImage(widget, self.k_weekImage, self.xMark[self.getDayCoords(self.thisDay)[0]], 50)
def showDayMarker(self, widget, update): if update == 0: self.k_dayMarker = karamba.createImage(widget, self.xMark[self.getDayCoords(self.thisDay)[0]], self.yMark[self.getDayCoords(self.thisDay)[1]], "images/daymark.png") else: karamba.moveImage(widget, self.k_dayMarker, self.xMark[self.getDayCoords(self.thisDay)[0]], self.yMark[self.getDayCoords(self.thisDay)[1]])
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