I'd really like that standard tk-widgets be enhanced with the
possibility to set a totally-transparent background.
This could be a great help when developing GUIs.
Imagine just a simple frame with some labels and buttons; at present,
if you want to change the frame's background color, you also have to
change the labels' background button.
Moreover, sometimes it is impossible to adapt the label's bg to the
underlying background : imagine a label 'placed' crossing two
underlying blocks of different colors ..
Just for these basic reasons, I *need* label-widgets with a transparent
background.
I hope it is not an impossible task for a Tk-core developer; after all,
'text-items' within a canvas have no solid background !
Just for a proof of concept, I'd like to have this feature for
label-widgets first; other standard widgets may come next
label / labelframe
frame
message
text
button (questionable)
canvas (questionable)
scrollbar (senseless?)
spinbox (senseless?)
toplevel ( I think no )
...
Eventually, if someone is able to enhance the standard widgets with
semi-transparent background ..
well, this would be a BIG plus ..
Your comments are welcome
Aldo
> This could be a great help when developing GUIs.
Great help when developing some kind of GUIs...
> Imagine just a simple frame with some labels and buttons; at present,
> if you want to change the frame's background color, you also have to
> change the labels' background button.
Yes. Consider just usual Mac OS X pinstripe background and things get
even more complex.
> Moreover, sometimes it is impossible to adapt the label's bg to the
> underlying background : imagine a label 'placed' crossing two
> underlying blocks of different colors ..
You can always fake such a label with the canvas.One common example for
this kind of label would be the typical progress bar with text inside
the bar.
>
> Just for these basic reasons, I *need* label-widgets with a transparent
> background.
>
> I hope it is not an impossible task for a Tk-core developer; after all,
> 'text-items' within a canvas have no solid background !
Probably not impossible. But most of the Tk-core developers have
personal todo list probably far too long already. So if at all your
proposal will end up on such an todo list.
>
> Just for a proof of concept, I'd like to have this feature for
> label-widgets first; other standard widgets may come next
> label / labelframe
> frame
> message
> text
> button (questionable)
> canvas (questionable)
> scrollbar (senseless?)
> spinbox (senseless?)
> toplevel ( I think no )
For toplevels this is actually more or less implemented, see:
wm attributes -alpha
Or the shape extension (http://wiki.tcl.tk/shape).
> Eventually, if someone is able to enhance the standard widgets with
> semi-transparent background ..
> well, this would be a BIG plus ..
Could be near to impossible for some platforms, where native widgets are
used, but i may be wrong.
But could be fun for some others.
Michael
Tk, for better or for worse, associates each widget on both X11 and Win
with a heavyweight window allocated from the underlying system. Most of
the time this is good, but it makes semi-transparency more difficult
(and non-uniform transparency doubly so!) This means that any attempt at
cracking this problem *must* find a way to make the Xserver/OS do the
real work of any semi-transparency for you.
I'm not saying it wouldn't be very cool indeed, but it is not a trivial
piece of programming...
Donal.
There's even more: Tk widgets draw themselves with a double-buffering
strategy; they allocate a temporary offscreen pixmap, draw themselves
onto that, and blit everything to the screen in one step.
(It works this way even on OSX, where there's not even any such thing
as a heavyweight internal window -- Tk emulates these internally --
and the double-buffering turns into triple-buffering.)
>I'm not saying it wouldn't be very cool indeed, but it is not a trivial
>piece of programming...
No, not trivial at all...
--Joe English
Let's come back to the original question:
* Do you think it is possible to have totally-transparent-background,
that is, widgets without 'solid background' painted (very closely
resembling a text-item on a canvas) ?
Note that it is not requested all classic-widgets be transparent;
probably for some of them it is a nonsense ...
A transparent botton ? Oh no, a button should be 'solid' ...
Just for few widgets this is a really important feature:
label
frame / labelframe
message
panedwindow
text
Having simplified the target, I think this would be a FUN challenge .
Don't you ?
Aldo Buratti
It's possible to define some parts of any widget as being transparent
with the help of an extension. I *believe* that:
http://www.cs.man.ac.uk/~fellowsd/tcl/shapeidx.html
is probably where you want to look for that, though I admit that code is
not well-maintained. (I'm just too short of time the whole time.) I'm
fairly sure it works on Unix/X, and it might well do with Windows too.
Going to the next step, a window that is transparent except for where it
is drawn, is quite a bit more difficult because Tk isn't designed to
work that way.
Donal.