Dear all, First of all, a short presentation since I'm new on the ML. I'm student in Belgium (UCLouvain) in Computer Science (especially computer langages and software engineering). I just started a small project (a game for gnome) to get familiar with Cairo and Pango libs.
I need two distinct drawing area in a gtk window. I tried a naive way
but I only get one working area (the first is accordingly filled with a
black rectangle, the other seems to be not displayed). I presume this is
not the right way to do it.
Here is the code:
#!/usr/bin/env python
#
import gtk, cairo
class DA(gtk.DrawingArea):
def __init__(self):
gtk.DrawingArea.__init__(self)
self.connect("expose_event", self.expose)
def expose(self, widget, event):
self.context = widget.window.cairo_create()
# set a clip region for the expose event
self.context.rectangle(event.area.x, event.area.y,
event.area.width,
event.area.height)
self.context.clip()
self.draw(self.context)
return False
def draw(self, context):
rect = self.get_allocation()
context.rectangle(rect.x, rect.y, rect.width, rect.height)
context.fill()
return False
def main():
window = gtk.Window()
da1 = DA()
da2 = DA()
vbox = gtk.VBox()
vbox.add(da1)
vbox.add(da2)
window.add(vbox)
window.connect("destroy", gtk.main_quit)
window.show_all()
gtk.main()
if __name__ == "__main__":
main()
and the result is attached.
Waiting for your help and of course, thanks in advance,
Antoine C.
--
Antoine Cailliau
www.ac-graphic.net
<<attachment: Screenshot-11.png>>
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
