import gtk import gtk.glade from cairo import * class SudoGridFace(gtk.DrawingArea): def __init__(self): super(SudoGridFace,self).__init__() self.connect("expose_event",self.expose) def expose(self,widget,event): context=widget.window.cairo_create() 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): context.save() rect = self.get_allocation() miny = rect.y+(rect.height*0.05) minx = rect.x+(rect.width*0.05) maxy = rect.y+(rect.height*0.95) maxx = rect.x+(rect.width*0.95) width = rect.width*0.9 height = rect.height*0.9 context.set_source_rgb(1,1,1) context.rectangle(minx,miny,width,height) context.fill_preserve() context.set_source_rgb(0,0,0) for i in range(0,10): currentx = minx+(width*i/9.0) currenty = miny+(height*i/9.0) context.move_to(minx,currenty) context.line_to(maxx,currenty) context.move_to(currentx,miny) context.line_to(currentx,maxy) context.stroke() context.restore() def main(): window = gtk.Window() table = gtk.Table(2,3) window.add(table) faces = list() for i in range(0,3): faces.insert(i,SudoGridFace()) table.attach(faces[i],i,i+1,0,1) table.attach(gtk.Label("salut"),i,i+1,1,2) window.connect("destroy",gtk.main_quit) window.show_all() gtk.main() if __name__ == "__main__": main()