Zaurus - dimmer

Here, I used the Zaurus to wirelessly dim the desk lamp. The PyQT program is below.

When I adjust a slider, the program sends messages over XMLRPC to a server on one of my desktop boxes. That box sends the levels to my K8000 IO card, which you can see in the background of the image. That card sends 0-10V control signals to 4 dimmers around the room.

#!/usr/bin/env python
from __future__ import division
import sys,xmlrpclib,socket
from qt import *
Vertical = 1

class Dimmer(QVBoxLayout):
    maxval = 300
    def __init__(self,parent,name,serv):
        QVBoxLayout.__init__(self)

        self.serv,self.name = serv,name

        lab = QLabel(name,parent)
        lab.setFont(QFont("Sans", 10))
        self.addWidget(lab)

        sli = QSlider(0,self.maxval,self.maxval//10,self.maxval,
                      Vertical,parent)
        self.addWidget(sli)

        self.connect(sli, SIGNAL('valueChanged(int)'), self.changed)

    def changed(self,val):
        val = 1-val/self.maxval
        self.serv.setLight(self.name,val)

class Dimmers(QWidget):
    def __init__(self, *args):
        QWidget.__init__(self, *args)

        self.serv = xmlrpclib.ServerProxy("http://dot.bigasterisk.com:%s" %
                                          socket.getservbyname("lights","tcp"))

        self.setCaption("Light dimmers")
        cols = QGridLayout(self, 2, 5)

        for pos,name in enumerate(self.serv.listLights()):
            dim = Dimmer(self, name, self.serv)
            cols.addLayout(dim, pos//5, pos%5)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.connect(app, SIGNAL('lastWindowClosed()'), app,
                  SLOT('quit()'))
    d = Dimmers()
    d.show()
    app.setMainWidget(d)
    app.exec_loop()