[Sugar-devel] Paint: how can use keys?

Gonzalo Odiard godiard at gmail.com
Mon May 31 23:47:10 EDT 2010


I am trying to use the keys with the circles with diferent sizes to change
the size of the tool, but didn't see any event.
Can anybody help me?

[gonzalo at aronax tmp]$ diff -u  /home/gonzalo/sugar-devel/paint.git/Area.py
Area.py
--- /home/gonzalo/sugar-devel/paint.git/Area.py    2010-05-31
00:54:19.000000000 -0300
+++ Area.py    2010-06-01 00:43:57.275948846 -0300
@@ -1123,6 +1123,7 @@
             logging.debug('Unexpected error: %s', message)

     def key_press(self,widget,event):
+        print "code",event.keyval
         if event.keyval == gtk.keysyms.BackSpace:
             if self.selmove:
                 self.selmove = False
@@ -1162,6 +1163,21 @@
             if self.tool['name'] == 'marquee-rectangular':
                 self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TCROSS))
             widget.queue_draw()
+        elif (event.keyval >= 65474) and (event.keyval <= 65477):
+            print "codigo",event.keyval
+            if self.tool['name'] in ['pencil','eraser','brush','rainbow']:
+                if event.keyval == 65474:
+                    self.tool['line size'] = self.tool['line size'] - 5
+                elif event.keyval == 65475:
+                    self.tool['line size'] = self.tool['line size'] - 1
+                elif event.keyval == 65476:
+                    self.tool['line size'] = self.tool['line size'] + 1
+                elif event.keyval == 65477:
+                    self.tool['line size'] = self.tool['line size'] + 5
+                widget.queue_draw()
+        else:
+            print "codigo no manejado",event.keyval
+

     def key_release(self,widget,event):
         pass

Gonzalo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20100601/57f2a7a4/attachment.htm 


More information about the Sugar-devel mailing list