예제 #1
0
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"
예제 #2
0
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
예제 #3
0
def widgetUpdated(widget):
    global bars, b
    
    # vertical & bitmap
    b = karamba.getBarVertical(widget, bars[7])
    print "getVertical: " + str(b)
    bmp = karamba.getBarImage(widget, bars[7])
    print "getBitmap: " + str(bmp)
    b = (b+1)%2
    karamba.setBarVertical(widget, bars[7], b)
    if(b):
      karamba.setBarImage(widget, bars[7], "ver.png")
      karamba.resizeBar(widget, bars[7], 20, 200)
    else:
      karamba.setBarImage(widget, bars[7], "hor.png")
      karamba.resizeBar(widget, bars[7], 200, 20)

    # size & resize
    size = karamba.getBarSize(widget, bars[1])
    print "getBarSize: " + str(size)
    size = ((b * 100) + 100, size[1])    
    karamba.resizeBar(widget, bars[1], size[0], size[1])
    
    # pos & move
    pos = karamba.getBarPos(widget, bars[2])
    print "getBarPos: " + str(pos)
    pos = (b * 200, pos[1])    
    karamba.moveBar(widget, bars[2], pos[0], pos[1])
    
    # Hide & Show
    if(b):
      karamba.hideBar(widget, bars[3])
    else:
      karamba.showBar(widget, bars[3])
    
    # Value
    v = karamba.getBarValue(widget, bars[5])
    print "getBarValue: ", v
    v = (v + 10) % 110
    karamba.setBarValue(widget, bars[5], v)
    
    # Min Max
    minmax = karamba.getBarMinMax(widget, bars[6])
    print "getBarMinMax: " + str(minmax)
    minmax = (0, (b * 100) + 100)    
    karamba.setBarMinMax(widget, bars[6], minmax[0], minmax[1])
    
    # Sensor
    sensor = karamba.getBarSensor(widget, bars[4])
    print "getSensor: " + str(sensor)
    if(b):
      karamba.setBarSensor(widget, bars[4], 'SENSOR=SENSOR TYPE="cpu_temp"')
    else:
      karamba.setBarSensor(widget, bars[4], 'SENSOR=CPU')
      
    # Create & delete
    if(bars[0]):
      karamba.deleteBar(widget, bars[0])
      bars[0] = 0
    else:
      bars[0] = karamba.createBar(widget, 0, 20, 200, 20)
      karamba.setBarImage(widget, bars[0], "hor.png")
      karamba.setBarValue(widget, bars[0], 100)