On Fri, Jan 16, 2004 at 03:33:12PM -0200, Christian Robottom Reis wrote:
> On Fri, Jan 16, 2004 at 04:41:22PM +0100, Antoon Pardon wrote:
> > I have just written my first application with a
> > gtk.DrawingArea. Can someone explain why I have to
> > do anything usefull with it I always have to
> > refer to the window attribute.
> 
> It probably stems from the fact that the DrawingArea is -- IIRC --
> almost entirely designed to wrap its GdkWindow. IOW, it doesn't have any
> [relevant] methods of its own; it's just designed to allow you to do GDK
> calls without any widget features (which would be pretty undesireable
> for a canvas anyway).

But if that is the purpose, why not use a GdkWinow instead of
the DrawingArea.
> 
> > Why not
> > 
> >   DA = gtk.DrawingArea()
> >   ...
> >   gc = DA.new_gc()
> >   DA.draw_point(gc , x , y)
> > 
> > instead of
> > 
> >   DA = gtk.DrawingArea()
> >   ...
> >   gc = DA.window.new_gc()
> >   DA.window.draw_point(gc , x , y)
> > 
> > The way it is done now just seems to
> > complicate things whithout good
> > reason.
> 
> Note that it *used* to be (in GTK-1.2 era) just like you suggested --
> the wrapper class for GtkDrawingArea proxied all its calls into its
> GdkWindow. I *think* James changed this because there was no longer a
> Python wrapper class in PyGTK-2.x, and perhaps to keep us as close as
> possible to the GTK+ bindings.
> 
> (Haven't I answered this before?)
> 
> At any rate, it's trivial to write a wrapper class in Python that
> proxies all calls to the GdkWindow; that is however left as an exercise
> to the reader <wink>.

It probably is. But it makes the tutorial a bit hard to understand.
Section 12.2 Talk about the drawing methods and introduces them as:

  drawable.draw_point ..., 

With a name as DrawingArea, that strongly suggests it is a drawable.
A newbee can hardlee know that it is not the drawingarea itself that
is a drawable but its window attribute 

In this case I would say that wrapping the methods in the demo adds
to the confusion. That is because the method to handle the expose
events comes first and there you just see area.draw_point, exactly
the same method name of a drawable. This reinforce the idea that
it is the drawing area that is the drawable.

Sure on a closer look one sees what is going on, but that doesn't
change the fact that it is confusing at first sight.

-- 
Antoon Pardon
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to