import monome


class SimpleTest(monome.Monome):
    def button_handler(self, event):
        x, y = event.x, event.y
        self.buttons[x][y] ^= 1

        if self.buttons[x][event.y]:
            self.led_on(x, y)
        else:
            self.led_off(x, y)

    def run(self):
        self.buttons = [[0 for x in xrange(0, 16)] for x in xrange(0, 16)]
        self.register_handler(monome.BUTTON_DOWN, self.button_handler)
        self.clear()

        print ("simple.py running, press some buttons!")

        try:
            self.main_loop()
        except:
            self.clear()
            self.close()

if __name__ == "__main__":
    app = SimpleTest("osc.udp://127.0.0.1:8080/monome", 8000)
    app.run()

@@ -12,46 +12,52 @@
 me%0A%0A
-%0Aclass SimpleTest(monome.Monome):%0A    
+device = %22osc.udp://127.0.0.1:8080/monome%22%0A%0A
 def 
@@ -75,22 +75,16 @@
 ler(
-self, 
 event):%0A
     
@@ -79,20 +79,16 @@
 event):%0A
-    
     x, y
@@ -107,33 +107,24 @@
 event.y%0A    
-    self.
 buttons%5Bx%5D%5By
@@ -135,24 +135,15 @@
  1%0A%0A
-    
     if 
-self.
 butt
@@ -163,32 +163,25 @@
 y%5D:%0A        
-    self
+m
 .led_on(x, y
@@ -182,20 +182,16 @@
 n(x, y)%0A
-    
     else
@@ -200,24 +200,17 @@
         
-    self
+m
 .led_off
@@ -221,40 +221,8 @@
 y)%0A%0A
-    def run(self):%0A        self.
 butt
@@ -279,28 +279,49 @@
 0, 16)%5D%0A
-        self
+m = monome.Monome(device, 8000)%0Am
 .registe
@@ -350,21 +350,16 @@
 N_DOWN, 
-self.
 button_h
@@ -370,44 +370,14 @@
 er)%0A
-        self.clear()%0A%0A        
+%0A
 print
- 
 (%22si
@@ -420,216 +420,72 @@
 %22)%0A%0A
-        try:%0A            self.main_loop()%0A        except:%0A            self.clear()%0A            self.close()%0A%0Aif __name__ == %22__main__%22:%0A    app = SimpleTest(%22osc.udp://127.0.0.1:8080/monome%22, 8000)%0A    app.run
+try:%0A%09m.main_loop()%0Aexcept KeyboardInterrupt:%0A%09m.clear()%0A%09m.close
 ()%0A

simplify simple.py