#!/usr/bin/env python import gtk, cairo import math class Values(object): pass def expose_event (win, event): w, h = win.get_size () cr = win.window.cairo_create () cr.rectangle (*event.area) cr.clip () cr.translate (w/2.0, h/2.0) cr.scale (min (w/2., h/2.), min (w/2., h/2.)) cr.scale (1./75, 1./75) cr.set_fill_rule (cairo.FILL_RULE_WINDING) cr.arc (-20, 0, 30, 0, 2 * math.pi) cr.arc_negative (20, 0, 25, 0, 2 * math.pi) cr.fill_preserve () cr.stroke () return True def setup_ui (): win = gtk.Window () win.set_default_size (150, 150) win.set_events (gtk.gdk.EXPOSURE_MASK) win.connect ("expose-event", expose_event) win.connect ("delete-event", gtk.main_quit) win.show_all () if __name__=='__main__': setup_ui () gtk.main ()