[pygtk] Custom Widgets (Movable Containers)

Wildemar Wildenburger wildemar at freakmail.de
Sun Jan 27 22:15:01 WST 2008


Gustavo J. A. M. Carneiro wrote:
>   A) Some people believe Gtk+ already has most things needed to draw
> complex GUIs, and you don't really need a "canvas".  Your little program
> is an excellent proof-of-concept of this idea;
>
>   
Damn! ;)
I'd sure like to see goocanvas integrated with (py)GTK.


>   B) Some people think that Gtk+ widget system has too many limitations
> and we should have a new canvas widget.  Among the limitations of Gtk+
> widget system are: 1. large overhead for creating widgets vs creating
> canvas items (e.g. X server round trip times for creating gdk windows,
> can have impact if creating thousands of items), 2. does not support
> layering of widgets with transparency and alpha channel, 3. does not
> properly support rotation/scaling.
>
>   
Since I'm not going to do any complex graphics, thousands of items, 
scaling, rotating, etc. this does'nt concern me much (Although the 
alpha-blending thingy seems tempting).

But on a more general scale, I think I'm much more in favor of B. I find 
the DrawingArea approach pretty kludgy, even if doable.

>> I have several questions now:
>>
>> How would I draw the boxes efficiently? When moving the Boxes around, 
>> the different borders will unhinge a little (so you can see cracks 
>> between them) and I don't want that.
>>     
>
> I don't see any cracks, here.  Have you tried running the program under
> a compositing manager?
>
>   
I must say, the cracks are much more visible when the borders are drawn 
black. This is more an issue of peace of mind. Even if you don't really 
see them much, they are there. And I'd like to release a program that 
makes people go "Man, this looks impressive. And so solid. Oh, and 
useful of course. ;)"

I've tried this under Metacity. I don't want to force people to use a 
compositing manager just for the program to look right. This should work 
no matter what.



>> I have considered drawing the border as a whole and then overlaying the 
>> left and right sides with eventboxes to add the current functionality. 
>> Is that preferable? What /is/ preferable?
>> How can I shape these boxes efficiently? I know that this is answered in 
>> the FAQ; I would like to know how to reuse what I have already drawn, as 
>> in: "Make this thing transparent, *except* for where I've drawn."
>>     
>
> Since gtk+ does not (AFAIR) support alpha compositing at the widget
> level, you have to create a gdk.Bitmap and use
> gdk.Window.shape_combine_mask().  See the FAQ:
>
> http://faq.pygtk.org/index.py?req=show&file=faq10.024.htp
>
> Hope this helps.
>
>   
Well, yeah, sort of. As I said, I knew about it, I just wanted to avoid 
calling the drawing methdods twice. I hoped I could somehow copy what 
I'd drawn before instead of drawing it again to the bitmap.

GTK not supporting alpha compositing sucks, BTW.

Anyways, thanks for the comments. :)

/W


More information about the pygtk mailing list