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 printEpisodeList(self): # Reset text if necessary for i in range( len( self.refEpisodeList ) ): # Remove click areas karamba.removeClickArea(Applet.widget, self.refEpisodeUrls[i]) # Remove text karamba.deleteText(Applet.widget, self.refEpisodeList[i]) karamba.deleteText(Applet.widget, self.refEpisodeListWhen[i]) self.refEpisodeUrls = [] self.refEpisodeList = [] self.refEpisodeListWhen = [] # Write episode list for i in range( len( self.episodeList ) ): color = self._processColor( self.episodeList[i]['delta'] ) posTitleY = self.themeHeaderWH[1] + ( self.themeBodyWH[1] * i ) + self.themeBodyTitleXY[1] posWhenY = self.themeHeaderWH[1] + ( self.themeBodyWH[1] * i ) + self.themeBodyWhenXY[1] episodeText = tools.formatEpisode( self.episodeList[i], self.episodeFormatString ) refT = karamba.createText(Applet.widget, self.themeBodyTitleXY[0], posTitleY, self.themeBodyTitleWH[0], self.themeBodyTitleWH[1], episodeText) karamba.changeTextColor(Applet.widget, refT, color[0], color[1], color[2]) self.refEpisodeList.append( refT ) cmd = self.browser.replace( "$url$", self.episodeList[i]['url'] ) refUrl = karamba.createClickArea(Applet.widget, self.themeBodyTitleXY[0], posTitleY, self.themeBodyTitleWH[0], self.themeBodyTitleWH[1], cmd) self.refEpisodeUrls.append( refUrl ) whenText = self._formatWhen( self.episodeList[i]['airdate'], self.episodeList[i]['delta'] ) refW = karamba.createText(Applet.widget, self.themeBodyWhenXY[0], posWhenY, self.themeBodyWhenWH[0], self.themeBodyWhenWH[1], whenText) karamba.changeTextColor(Applet.widget, refW, color[0], color[1], color[2]) karamba.setTextAlign(Applet.widget, refW, "CENTER") karamba.attachClickArea(Applet.widget, refW) self.refEpisodeListWhen.append( refW )
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 expected_seq # i hate globals. please write better code than this example. # get the "message"... disp = karamba.getIncomingData(widget) if disp == "": return # decode it... (seq, x, y, button) = eval(disp) # if it's been seen before, skip it... if seq <= expected_seq: pass expected_seq += 1 message = "seq:%d x:%d y:%d btn:%d" % (seq, x, y, button) # delete previous text if exists. global drop_txt if drop_txt is not None: karamba.deleteText(widget, drop_txt) # display it... drop_txt = karamba.createText(widget, 0, 20, 300, 20, message) karamba.changeTextColor(widget, drop_txt, 252,252,252) karamba.redrawWidget(widget) pass
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 widgetUpdated(widget): global expected_seq # i hate globals. please write better code than this example. # get the "message"... disp = karamba.getIncomingData(widget) if disp == "": return # decode it... (seq, x, y, button) = eval(disp) # if it's been seen before, skip it... if seq <= expected_seq: pass expected_seq += 1 message = "seq:%d x:%d y:%d btn:%d" % (seq, x, y, button) # delete previous text if exists. global drop_txt if drop_txt is not None: karamba.deleteText(widget, drop_txt) # display it... drop_txt = karamba.createText(widget, 0, 20, 300, 20, message) karamba.changeTextColor(widget, drop_txt, 252, 252, 252) karamba.redrawWidget(widget) pass
def meterClicked(widget, meter, button): global urlpointer, update drin = 0 if meter == fill[0] and button == 1: drin = 1 urlpointer = 0 elif meter == fill[1] and button == 1: urlpointer = 1 drin = 1 elif meter == fill[2] and button == 1: urlpointer = 2 drin = 1 elif meter == clickScrollUp: print "Scroll Up" update = 0 fillContent(widget,"up") elif meter == clickScrollDown: print "Scroll Down" update = 0 fillContent(widget,"down") if drin == 1: print "Click Menu" createMenu(widget) karamba.changeTextColor(widget, fill[urlpointer], 54,227,123) # karamba.changeTextColor(widget, fill[urlpointer], 255,255,255) update = 0 fillContent(widget, "refresh")
def initWidget(widget): global input, output #input = karamba.getThemeInputBox(widget, "input01") input = karamba.createInputBox(widget,0,0,50,20,"foo") output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def initWidget(widget): global input, output #input = karamba.getThemeInputBox(widget, "input01") input = karamba.createInputBox(widget, 0, 0, 50, 20, "foo") output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def initWidget(widget): global input1, input2, output, fontSize #input = karamba.getThemeInputBox(widget, "input01") input1 = karamba.createInputBox(widget,0,0,50,20,"foo") input2 = karamba.createInputBox(widget,0,30,50,20,"bar") fontSize = karamba.getInputBoxFontSize(widget, input2) output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def initWidget(widget): global input1, input2, output, fontSize #input = karamba.getThemeInputBox(widget, "input01") input1 = karamba.createInputBox(widget, 0, 0, 50, 20, "foo") input2 = karamba.createInputBox(widget, 0, 30, 50, 20, "bar") fontSize = karamba.getInputBoxFontSize(widget, input2) output = karamba.getThemeText(widget, "output01") karamba.changeTextColor(widget, output, 0, 0, 0) karamba.changeTextSize(widget, output, 10) karamba.redrawWidget(widget)
def printTop(self, widget, update): if update == 0: self.k_MonthCaption = karamba.createText(widget, 25, 17, 200, 50, self.monthString) karamba.changeTextColor(widget, self.k_MonthCaption, 255, 255, 255) karamba.changeTextSize(widget, self.k_MonthCaption, 20) self.k_YearCaption = karamba.createText(widget, 160, 17, 200, 50, self.yearString) karamba.changeTextColor(widget, self.k_YearCaption, 255, 255, 255) karamba.changeTextSize(widget, self.k_YearCaption, 22) else: karamba.changeText(widget, self.k_MonthCaption, self.monthString) karamba.changeText(widget, self.k_YearCaption, self.yearString)
def itemDropped(widget, dropText, x, y): global drop_txt # delete previous text if exists. if drop_txt is not None: karamba.deleteText(widget, drop_txt) disp = "x:%d y:%d command: %s" % (x, y, dropText) drop_txt = karamba.createText(widget, 10, 40, 500, 20, disp) karamba.changeTextColor(widget, drop_txt, 252,252,252) karamba.redrawWidget(widget)
def printDayCaptions(self, widget, update): if update != 0: i = 0 while i <= 6: karamba.deleteText(widget, self.k_dayCaption[i]) i = i + 1 i = 0 while i <= 6: self.k_dayCaption[i] = karamba.createText(widget, self.xPosition[i], 50, 200, 50, self.dayArray[i]) karamba.changeTextFont(widget, self.k_dayCaption[i], "arialbd") karamba.changeTextColor(widget, self.k_dayCaption[i], 255, 255, 255) i = i + 1 karamba.changeTextColor(widget, self.k_dayCaption[self.thisWeekday], 255, 255 , 255)
def widgetClicked(widget, x, y, button): global do_nothing_txt if y < 20: if do_nothing_txt is not None: karamba.deleteText(widget, do_nothing_txt) do_nothing_txt = karamba.createText( widget, 0, 0, 300, 20, "I don't do anything when clicking here.") karamba.changeTextColor(widget, do_nothing_txt, 255, 200, 200) karamba.redrawWidget(widget) return karamba.managementPopup(widget)
def widgetClicked(widget, x, y, button): global do_nothing_txt if y < 20: if do_nothing_txt is not None: karamba.deleteText(widget, do_nothing_txt) do_nothing_txt = karamba.createText(widget, 0, 0, 300, 20, "I don't do anything when clicking here.") karamba.changeTextColor(widget, do_nothing_txt, 255,200,200) karamba.redrawWidget(widget) return karamba.managementPopup(widget)
def printEpisodeList(self): # Reset text if necessary for i in range(len(self.refEpisodeList)): # Remove click areas karamba.removeClickArea(Applet.widget, self.refEpisodeUrls[i]) # Remove text karamba.deleteText(Applet.widget, self.refEpisodeList[i]) karamba.deleteText(Applet.widget, self.refEpisodeListWhen[i]) self.refEpisodeUrls = [] self.refEpisodeList = [] self.refEpisodeListWhen = [] # Write episode list for i in range(len(self.episodeList)): color = self._processColor(self.episodeList[i]['delta']) posTitleY = self.themeHeaderWH[1] + (self.themeBodyWH[1] * i) + self.themeBodyTitleXY[1] posWhenY = self.themeHeaderWH[1] + (self.themeBodyWH[1] * i) + self.themeBodyWhenXY[1] episodeText = tools.formatEpisode(self.episodeList[i], self.episodeFormatString) refT = karamba.createText(Applet.widget, self.themeBodyTitleXY[0], posTitleY, self.themeBodyTitleWH[0], self.themeBodyTitleWH[1], episodeText) karamba.changeTextColor(Applet.widget, refT, color[0], color[1], color[2]) self.refEpisodeList.append(refT) cmd = self.browser.replace("$url$", self.episodeList[i]['url']) refUrl = karamba.createClickArea(Applet.widget, self.themeBodyTitleXY[0], posTitleY, self.themeBodyTitleWH[0], self.themeBodyTitleWH[1], cmd) self.refEpisodeUrls.append(refUrl) whenText = self._formatWhen(self.episodeList[i]['airdate'], self.episodeList[i]['delta']) refW = karamba.createText(Applet.widget, self.themeBodyWhenXY[0], posWhenY, self.themeBodyWhenWH[0], self.themeBodyWhenWH[1], whenText) karamba.changeTextColor(Applet.widget, refW, color[0], color[1], color[2]) karamba.setTextAlign(Applet.widget, refW, "CENTER") karamba.attachClickArea(Applet.widget, refW) self.refEpisodeListWhen.append(refW)
def initWidget(widget): global do_nothing_txt global do_something_txt # display new message do_nothing_txt = karamba.createText(widget, 0, 00, 300, 20, "Right mouse click me!") karamba.changeTextColor(widget, do_nothing_txt, 252,252,252) mgmt_txt = karamba.createText(widget, 0, 20, 300, 20, "Righ mouse click me too!") karamba.changeTextColor(widget, mgmt_txt, 252,252,252) karamba.redrawWidget(widget) karamba.setWantRightButton(widget, 1)
def initWidget(widget): global do_nothing_txt global do_something_txt # display new message do_nothing_txt = karamba.createText(widget, 0, 00, 300, 20, "Right mouse click me!") karamba.changeTextColor(widget, do_nothing_txt, 252, 252, 252) mgmt_txt = karamba.createText(widget, 0, 20, 300, 20, "Righ mouse click me too!") karamba.changeTextColor(widget, mgmt_txt, 252, 252, 252) karamba.redrawWidget(widget) karamba.setWantRightButton(widget, 1)
def create_text(widget, line, depth, disp, name=None, command=None, icon=None): x = depth * 30 y = line * 7 width = 400 height = 8 drop_txt = karamba.createText(widget, x, y, width, height, disp) karamba.changeTextSize(widget, drop_txt, 7) karamba.changeTextColor(widget, drop_txt, 252, 252, 252) # create a (very narrow! only an 8-pixel-high area!) # service click area to demonstrate that commands get # executed correctly. if name: karamba.createServiceClickArea(widget, x, y, width, height, name, command, icon)
def create_text(widget, line, depth, disp, name=None, command=None, icon=None): x = depth*30 y = line*7 width = 400 height = 8 drop_txt = karamba.createText(widget, x, y, width, height, disp) karamba.changeTextSize(widget, drop_txt, 7) karamba.changeTextColor(widget, drop_txt, 252,252,252) # create a (very narrow! only an 8-pixel-high area!) # service click area to demonstrate that commands get # executed correctly. if name: karamba.createServiceClickArea( widget, x,y,width,height, name, command, icon)
def printCalendar(self, widget, update): if update != 0: j = 0 while j <= 4: i = 0 while i <= 6: karamba.deleteText(widget, self.k_dayField[j][i]) i = i + 1 j = j + 1 j = 0 while j <= 4: i = 0 while i <= 6: self.k_dayField[j][i] = karamba.createText(widget, self.xPosition[i], self.yPosition[j], 200, 50, str(self.calendarArray[j][i])) karamba.changeTextColor(widget, self.k_dayField[j][i], 255, 255, 255) karamba.changeTextFont(widget, self.k_dayField[j][i], "Arial") if self.calendarArray[j][i] == 0: karamba.hideText(widget, self.k_dayField[j][i]) i = i + 1 j = j + 1
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 createMenu(widget): global fill ## Set Title Heise ## getTitle() #first = karamba.createText(widget, 14, 1, 50, line_height, "Heise:") #setStyle(widget, first, 7, 15) #karamba.changeTextColor(widget, first, r,g,b) fill.insert(0, karamba.createText(widget, 90, 1, 50, line_height, "Online")) setStyle(widget, fill[0], 7, 15) karamba.changeTextColor(widget, fill[0], r,g,b) karamba.attachClickArea(widget, fill[0], "") ## Set Title Mobile fill.insert(1, karamba.createText(widget, 175, 1, 50, line_height, "Mobil")) setStyle(widget, fill[1], 7, 15) karamba.changeTextColor(widget, fill[1], r,g,b) karamba.attachClickArea(widget, fill[1], "") ## Set Title Security fill.insert(2, karamba.createText(widget, 255, 1, 60, line_height, "Security")) setStyle(widget, fill[2], 7, 15) karamba.changeTextColor(widget, fill[2], r,g,b) karamba.attachClickArea(widget, fill[2], "") ## Set Description getDescription()
def fillContent(widget, what): global itempointer, scroll if what == "up": scroll = scroll - 12 if scroll < 1: scroll = 0 elif what == "down": scroll = scroll + 3 max_start = item_cnt - lines if scroll > max_start: scroll = max_start elif what == "refresh": getHeise(heise_url[urlpointer]) getDescription() getItem() scroll = 0 z = 0 y_pos = 23 print "\n#### Fill Content ####" while scroll < item_cnt and z < lines: news = item[scroll] link_to = link[scroll] print item[scroll] content = karamba.changeText(widget, itempointer[z], news[:49]+' ...') setStyle(widget, content, 1, 17) karamba.changeTextColor(widget, content, r,g,b) cmd = browserCommand.split() cmd_link = cmd[0] + " "+link_to karamba.attachClickArea(widget, content, cmd_link) y_pos = y_pos + 15 scroll = scroll + 1 z = z + 1 print "#### End Content ####\n" if scroll == 10: scroll = 0
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 widgetUpdated(widget): global seq global text seq -= 1 if seq <= 0: karamba.changeInterval(widget, 1000) if seq <= 0: message = "biding-time seq:%d" % -seq else: message = "wiggle seq:%d" % seq # delete previous text if exists. if text is not None: karamba.deleteText(widget, text) # display new message text = karamba.createText(widget, 0, 20, 300, 20, message) karamba.changeTextColor(widget, text, 252, 252, 252) karamba.redrawWidget(widget)
def widgetUpdated(widget): global seq global text seq -= 1 if seq <= 0: karamba.changeInterval(widget, 1000) if seq <= 0: message = "biding-time seq:%d" % -seq else: message = "wiggle seq:%d" % seq # delete previous text if exists. if text is not None: karamba.deleteText(widget, text) # display new message text = karamba.createText(widget, 0, 20, 300, 20, message) karamba.changeTextColor(widget, text, 252,252,252) karamba.redrawWidget(widget)
def colorizeDay(self, widget, day, r, g, b): karamba.changeTextColor(widget, self.k_dayField[self.getDayCoords(day)[1]][self.getDayCoords(day)[0]], r, g, b)
def widgetUpdated(widget): global texts, b, a b = (b + 1) % 2 # Create & delete if (texts[0]): karamba.deleteText(widget, texts[0]) texts[0] = 0 else: texts[0] = karamba.createText(widget, 0, 20, 200, 20, "Text meter") # size & resize size = karamba.getTextSize(widget, texts[1]) print "getTextSize: " + str(size) size = ((b * 200) + 200, size[1]) karamba.resizeText(widget, texts[1], size[0], size[1]) # pos & move pos = karamba.getTextPos(widget, texts[2]) print "getTextPos: " + str(pos) pos = (b * 200, pos[1]) karamba.moveText(widget, texts[2], pos[0], pos[1]) # Hide & Show if (b): karamba.hideText(widget, texts[3]) else: karamba.showText(widget, texts[3]) # Sensor sensor = karamba.getTextSensor(widget, texts[4]) print "getSensor: " + str(sensor) if (b): karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') else: karamba.setTextSensor(widget, texts[4], 'SENSOR=CPU') # Value v = karamba.getTextValue(widget, texts[5]) print "getTextValue: ", v v += '.' karamba.changeText(widget, texts[5], v) # Shadow v = karamba.getTextShadow(widget, texts[6]) print "getTextShadow: ", v v = (v + 1) % 10 karamba.changeTextShadow(widget, texts[6], v) # Font size v = karamba.getTextFontSize(widget, texts[7]) print "getTextFontSize: ", v v = 10 + ((v - 10) + 1) % 10 karamba.changeTextSize(widget, texts[7], v) # Text color v = karamba.getTextColor(widget, texts[8]) print "getTextColor: ", v karamba.changeTextColor(widget, texts[8], b * 255, b * 255, b * 255) # Text Font v = karamba.getTextFont(widget, texts[9]) print "getTextFont: ", v if (b): v = 'Bitstream Vera Sans' else: v = 'Bitstream Vera Serif' karamba.changeTextFont(widget, texts[9], v) # Text Alignment a = (a + 1) % 3 v = karamba.getTextAlign(widget, texts[10]) print "getTextAlign: ", v karamba.setTextAlign(widget, texts[10], align[a])
#### Begin reading optional settings for titletext #### titletext_value = karamba.readConfigEntry(widget, "titletext_value") if titletext_value == None: try: titletext_value = theme_cfg.get( "karamba", "titletext_value" ) karamba.changeText(widget, titletext, titletext_value.strip()) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeText(widget, titletext, titletext_value.strip()) titletext_color = karamba.readConfigEntry(widget, "titletext_color") if titletext_color == None or titletext_color == "": try: r, g, b = theme_cfg.get( "karamba", "titletext_color" ).split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: r, g, b = titletext_color.split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) titletext_shadow = karamba.readConfigEntry(widget, "titletext_shadow") if titletext_shadow == None or str(titletext_shadow) == "": try: titletext_shadow = theme_cfg.getint( "karamba", "titletext_shadow" ) karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextShadow(widget, titletext, int(titletext_shadow))
#### Begin reading optional settings for titletext #### titletext_value = karamba.readConfigEntry(widget, "titletext_value") if titletext_value == None: try: titletext_value = theme_cfg.get("karamba", "titletext_value") karamba.changeText(widget, titletext, titletext_value.strip()) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeText(widget, titletext, titletext_value.strip()) titletext_color = karamba.readConfigEntry(widget, "titletext_color") if titletext_color == None or titletext_color == "": try: r, g, b = theme_cfg.get("karamba", "titletext_color").split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: r, g, b = titletext_color.split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) titletext_shadow = karamba.readConfigEntry(widget, "titletext_shadow") if titletext_shadow == None or str(titletext_shadow) == "": try: titletext_shadow = theme_cfg.getint("karamba", "titletext_shadow") karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextShadow(widget, titletext, int(titletext_shadow))
def drawTaskbar(widget): global taskPanels global taskText global numOfTasks taskList = karamba.getTaskList(widget) for image in taskPanels: karamba.hideImage(widget, image) for text in taskText: karamba.changeText(widget, text, "") karamba.changeTextShadow(widget, text, 0) karamba.changeTextColor(widget, text, 0, 0, 0) length = len(taskList) if numOfTasks < length: length = numOfTasks knownGroups = {} groups = [] groupRefs = {} activeGroup = 0 groupCount = 0 # build groups list that contains sub-lists of taskInfo sorted by group for j in range(len(taskList)): taskinfo = karamba.getTaskInfo(widget, taskList[j]) if knownGroups.has_key(taskinfo[2]) == 0: groupCount = groupCount + 1 if taskinfo[7] == 1: activeGroup = groupCount knownGroups[taskinfo[2]] = 1 thisGroup = [] thisGroup.append(taskinfo) groupRefs[taskinfo[2]] = len(groups) groups.append(thisGroup) else: if taskinfo[7] == 1: activeGroup = groupRefs[taskinfo[2]] + 1 knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1 thisGroup = groups[groupRefs[taskinfo[2]]] thisGroup.append(taskinfo) # fill out the task bar j = 0 for group in groups: # safety check (could be more task groups than bar is long) if j < length: karamba.showImage(widget, taskPanels[j]) if len(group) != 1: karamba.changeText(widget, taskText[j], group[0][2] + " [" + str(len(group)) + "]") else: karamba.changeText(widget, taskText[j], (group[0][0])) j = j + 1 if activeGroup != 0: karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1) karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11) karamba.redrawWidget(widget)
def colorizeWeek(self, widget, r, g, b): i = 0 while i <= 4: karamba.changeTextColor(widget, self.k_dayField[i][self.thisWeekday], r, g , b) i = i + 1 #print calendar.getDayCoords(20)
def widgetUpdated(widget): global texts, b, a b = (b + 1) % 2 # Create & delete if texts[0]: karamba.deleteText(widget, texts[0]) texts[0] = 0 else: texts[0] = karamba.createText(widget, 0, 20, 200, 20, "Text meter") # size & resize size = karamba.getTextSize(widget, texts[1]) print "getTextSize: " + str(size) size = ((b * 200) + 200, size[1]) karamba.resizeText(widget, texts[1], size[0], size[1]) # pos & move pos = karamba.getTextPos(widget, texts[2]) print "getTextPos: " + str(pos) pos = (b * 200, pos[1]) karamba.moveText(widget, texts[2], pos[0], pos[1]) # Hide & Show if b: karamba.hideText(widget, texts[3]) else: karamba.showText(widget, texts[3]) # Sensor sensor = karamba.getTextSensor(widget, texts[4]) print "getSensor: " + str(sensor) if b: karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') else: karamba.setTextSensor(widget, texts[4], "SENSOR=CPU") # Value v = karamba.getTextValue(widget, texts[5]) print "getTextValue: ", v v += "." karamba.changeText(widget, texts[5], v) # Shadow v = karamba.getTextShadow(widget, texts[6]) print "getTextShadow: ", v v = (v + 1) % 10 karamba.changeTextShadow(widget, texts[6], v) # Font size v = karamba.getTextFontSize(widget, texts[7]) print "getTextFontSize: ", v v = 10 + ((v - 10) + 1) % 10 karamba.changeTextSize(widget, texts[7], v) # Text color v = karamba.getTextColor(widget, texts[8]) print "getTextColor: ", v karamba.changeTextColor(widget, texts[8], b * 255, b * 255, b * 255) # Text Font v = karamba.getTextFont(widget, texts[9]) print "getTextFont: ", v if b: v = "Bitstream Vera Sans" else: v = "Bitstream Vera Serif" karamba.changeTextFont(widget, texts[9], v) # Text Alignment a = (a + 1) % 3 v = karamba.getTextAlign(widget, texts[10]) print "getTextAlign: ", v karamba.setTextAlign(widget, texts[10], align[a])
def drawTaskbar(widget): global taskPanels global taskText global numOfTasks taskList = karamba.getTaskList(widget) for image in taskPanels: karamba.hideImage(widget, image) for text in taskText: karamba.changeText(widget, text, "") karamba.changeTextShadow(widget, text, 0) karamba.changeTextColor(widget, text, 0, 0, 0) length = len(taskList) if (numOfTasks < length): length = numOfTasks knownGroups = {} groups = [] groupRefs = {} activeGroup = 0 groupCount = 0 #build groups list that contains sub-lists of taskInfo sorted by group for j in range(len(taskList)): taskinfo = karamba.getTaskInfo(widget, taskList[j]) if knownGroups.has_key(taskinfo[2]) == 0: groupCount = groupCount + 1 if (taskinfo[7] == 1): activeGroup = groupCount knownGroups[taskinfo[2]] = 1 thisGroup = [] thisGroup.append(taskinfo) groupRefs[taskinfo[2]] = len(groups) groups.append(thisGroup) else: if (taskinfo[7] == 1): activeGroup = groupRefs[taskinfo[2]] + 1 knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1 thisGroup = groups[groupRefs[taskinfo[2]]] thisGroup.append(taskinfo) #fill out the task bar j = 0 for group in groups: #safety check (could be more task groups than bar is long) if (j < length): karamba.showImage(widget, taskPanels[j]) if len(group) != 1: karamba.changeText(widget, taskText[j], group[0][2] + " [" + str(len(group)) + "]") else: karamba.changeText(widget, taskText[j], (group[0][0])) j = j + 1 if (activeGroup != 0): karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1) karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11) karamba.redrawWidget(widget)