rendered paste bodyimport gtk
import gtk.glade
from cairo import *
class SudoGridFace(gtk.DrawingArea):
def __init__(self):
super(SudoGridFace,self).__init__()
self.set_size_request(50,50)
self.connect("expose_event",self.expose)
def expose(self,widget,event):
print "expose", widget
self.draw()
return False
def draw(self):
context=self.window.cairo_create()
rect = self.get_allocation()
miny = (rect.height*0.05)
minx = (rect.width*0.05)
maxy = (rect.height*0.95)
maxx = (rect.width*0.95)
print rect.x, rect.y, rect.width, rect.height
print miny, minx, maxy, maxx
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()
def main():
window = gtk.Window()
window.set_default_size(640,480)
table = gtk.Table(2,3)
window.add(table)
faces = list()
for i in range(0,3):
faces.append(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()