> You want a gtk.Layout. It lets you place widgets at explicit
> positions in a 32-bit coordinate system and can be scrolled.
>
Thanks for the tip. I'm not getting closer. If you have a moment, could you 
look at this code?

\d

#!/usr/bin/env python

import gtk
import math

class Thing(gtk.DrawingArea):
    def __init__(self):
        super(Thing, self).__init__()
        self.connect("expose_event", self.expose)
        print "Thing __init__ called"

    def expose(self, widget, event):
        print "Thing expose called"
        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): pass
    def rect(self):
        return self.get_allocation()

class Box(Thing):
    #override draw
    def draw(self,context):
        r = self.rect()
        context.set_source_rgb(0.5, 0.5, 0.5)
        context.rectangle(1, 1, 10, 10)
        context.fill()
            
class RedBox(Thing):
    def draw(self,context):
        r = self.rect()
        context.set_source_rgb(1, 0, 0)
        context.rectangle(20, 20, 50, 50)
        context.fill()

def main():
    window = gtk.Window()
    window.set_size_request(300, 300)
    window.connect('delete-event', gtk.main_quit)

    sw = gtk.Layout()
    window.add(sw)

    rb = RedBox()
    b  = Box()
    #How to put them at x,y? And later, drag them?

    sw.add(b)
    sw.add(rb)
    
    rb.show()
    b.show()
    sw.show()
    
    window.show_all()
    gtk.main()
    
if __name__ == "__main__":
    main()
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to