def meterClicked(widget, meter, button): """ This gets called when a meter (image, text, etc) is clicked. NOTE you must use attachClickArea() to make a meter clickable. widget = reference to your theme meter = the meter clicked button = the button clicked """ global active global raised_alarm global curtime if meter == startButton: if active == 0: print "startButton" karamba.showBar(widget, progressBar) if zerotime.time < alarmtime.time: karamba.setBarMinMax(widget, progressBar, \ zerotime.time, alarmtime.time) else: karamba.setBarMinMax(widget, progressBar, \ alarmtime.time, zerotime.time) karamba.setBarValue(widget, progressBar, curtime.time) karamba.hideImage(widget, done) karamba.setImagePath(widget, startButton, "img/startpause.png") karamba.setImagePath(widget, endButton, "img/stoppause.png") active = 1 else: print "startButton (Pause)" karamba.setImagePath(widget, startButton, "img/start.png") karamba.setImagePath(widget, endButton, "img/stop.png") active = 0 elif meter == endButton: if active == 0: print "endButton" curtime = zerotime.copy() showTime(widget, curtime) karamba.showImage(widget, done) karamba.hideBar(widget, progressBar) curtimefh = open(curtimefile, "w") curtimefh.write(str(curtime)) curtimefh.close() karamba.setImagePath(widget, startButton, "img/start.png") karamba.setImagePath(widget, endButton, "img/stop.png") raised_alarm = False else: print "endButton (Pause)" karamba.setImagePath(widget, startButton, "img/start.png") karamba.setImagePath(widget, endButton, "img/stop.png") active = 0 elif meter == done: print "done" alarmtime.from_string(getValue(widget, "Alarm Time", str(alarmtime))) karamba.writeConfigEntry(widget, "alarmtime", str(alarmtime)) else: print "anotherbutton"
def meterClicked(widget, meter, button): global penguin global penguin_hidden global richtext print "Meter clicked", meter if meter == "trigger": if penguin_hidden: karamba.showImage(widget, penguin) penguin_hidden = 0 else: karamba.hideImage(widget, penguin) penguin_hidden = 1 if meter == "delete": karamba.deleteRichText(widget, richtext) karamba.redrawWidget(widget)
def widgetUpdated(widget): """ This is called every time the widget is updated. The update interval is specified in the .theme file """ global active global raised_alarm stopwatchmode = (zerotime.time < alarmtime.time) if active == 1: # increment/decrement, depending on mode if stopwatchmode: stepmethod = curtime.increment else: stepmethod = curtime.decrement try: stepmethod() except ValueError: # stop, instead of going below zero print "caught time going below zero" meterClicked(widget, endButton, 1) # reflect new time in GUI showTime(widget, curtime) if stopwatchmode: karamba.setBarValue(widget, progressBar, curtime.time) else: karamba.setBarValue(widget, progressBar, \ alarmtime.time + zerotime.time - curtime.time) karamba.redrawWidget(widget) # write current time to file curtimefh = open(curtimefile, "w") curtimefh.write(str(curtime)) curtimefh.close() # alarm? if not raised_alarm: if (stopwatchmode and (curtime.time >= alarmtime.time)) \ or (not stopwatchmode and (curtime.time <= alarmtime.time)): karamba.showImage(widget, done) karamba.redrawWidget(widget) alarm(widget) raised_alarm = True
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 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 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 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