diff options
author | Daniel Francis <francis@sugarlabs.org> | 2012-07-18 02:55:07 (GMT) |
---|---|---|
committer | Daniel Francis <francis@sugarlabs.org> | 2012-07-18 02:55:07 (GMT) |
commit | b68b7589594b91a17e0d7734e9baa727c4cfa724 (patch) | |
tree | fa2af49cbb60acc8590b382d3ffbc39cf3ceb192 | |
parent | 438f1bf3ca9f31d086a1adcd252ae2f873dec9a4 (diff) |
Draw staff
-rw-r--r-- | canvas.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -22,6 +22,25 @@ import gtk class StaffCanvas(gtk.DrawingArea): + width = None + def __init__(self): gtk.DrawingArea.__init__(self) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) + self.connect('expose-event', self._expose_event_cb) + + def _expose_event_cb(self, widget, event): + window = widget.get_window() + context = window.cairo_create() + self.width = event.area[2] + height = event.area[3] + self.draw_staff(context, 50, self.width * 0.1, self.width * 0.05, + height * 0.025) + + def draw_staff(self, context, y, lmarg, rmarg, spacing): + line_y = y + for i in range(5): + context.move_to(lmarg, line_y) + context.line_to(self.width - rmarg, line_y) + line_y += spacing + context.stroke() |