Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmpc <jumapico@gmail.com>2009-10-27 05:07:54 (GMT)
committer jmpc <jumapico@gmail.com>2009-10-27 05:07:54 (GMT)
commitdc862c435880fe415c53b534b09ccdb802075ce9 (patch)
tree306ba5e7806d7fd5d5eecb0f43c0eba8ebfecebe
parentc96f2c1fe500d97e30eb1e71766404bf71fd53f5 (diff)
Dibujamos en el interior del widget.
-rwxr-xr-xcake.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/cake.py b/cake.py
index 8abf1dc..8e2b967 100755
--- a/cake.py
+++ b/cake.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- encoding: utf8 -*-
+import math
import gtk
@@ -10,9 +11,26 @@ class Cake(gtk.DrawingArea):
def expose(self, widget, event):
+ context = widget.window.cairo_create()
+ # set a clip region for the expose event
+ context.rectangle(event.area.x, event.area.y, event.area.width, event.area.height)
+ context.clip()
+ self.draw(context)
return False
+ def draw(self, context):
+ rect = self.get_allocation()
+ x = rect.x + rect.width / 2
+ y = rect.y + rect.height / 2
+ radius = min(rect.width / 2, rect.height / 2) - 5
+ context.arc(x, y, radius, 0, 2 * math.pi)
+ context.set_source_rgb(1, 1, 1)
+ context.fill_preserve()
+ context.set_source_rgb(0, 0, 0)
+ context.stroke()
+
+
def main():
window = gtk.Window()
cake = Cake()