For Programmers: Free Programming Magazines  


Home > Archive > Tcl > November 2006 > Re: transparency









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: transparency
Jeff Hobbs

2006-11-29, 4:09 am

Kyle wrote:
> as a tutorial project i tried to create a simple digital clock (which is
> pretty easy task), however i wanted it to look (:
>
> and here comes my problem, id like my clock to appear on desktop as
> digits only, but cant find a way to make label's background transparent
>
> im aware that there are some problems with tk with regard to
> transparency (did bit of google search), but i wonder whether its
> possible to arrive at solution to this particular problem (doesnt have
> to be general, and may include some external libraries, however id like
> to stick to tcl)


The problem isn't with Tk per se, but that this is inherently something
that isn't easy to do across platforms. There are extensions to Tk for
X11 Shape and Win32 shaped toplevels (tktrans). However, those won't
make what you want easier, because you are intending to change the shape
of the toplevel every second.

This is theoretically possible, but it depends on the platform. I know
how to do it on Win32, but not other platforms.

--

Jeff Hobbs, The Tcl Guy, http://www.activestate.com/
Uwe Klein

2006-11-29, 4:09 am

Jeff Hobbs wrote:
> Kyle wrote:
>
[color=darkred]
> This is theoretically possible, but it depends on the platform. I know
> how to do it on Win32, but not other platforms.
>

What about using unmanaged/undecorated toplevels for the segments?
withdraw and place as you like it.
Ok, the segments can only be rectangles.

uwe
Uwe Klein

2006-11-29, 7:08 pm

Kyle wrote:

> well i actually want it to run on windows platform (should have
> mentioned it earlier, sorry), so if you could elaborate more, and at
> last point me in the right direction i would be grateful


Transparent Toplevel ( for some MS versions):
http://wiki.tcl.tk/10515
you may want to search for more on the wiki:
http://wiki.tcl.tk/2?transpa
http://wiki.tcl.tk/2?transpa*

Lots of fun

uwe
Bryan Oakley

2006-11-29, 7:08 pm

Uwe Klein wrote:
> Kyle wrote:
>
>
> Transparent Toplevel ( for some MS versions):
> http://wiki.tcl.tk/10515
> you may want to search for more on the wiki:
> http://wiki.tcl.tk/2?transpa
> http://wiki.tcl.tk/2?transpa*
>
> Lots of fun
>
> uwe


I think the problem with transparent toplevels as implemented in the
core is, whatever alpha you give the toplevel applies to all widgets in
the toplevel. That is, you can't make the toplevel 100% transparent and
have a 100% solid label widget inside.

Too bad. I could find uses for that.

Jeff Hobbs

2006-11-30, 4:16 am

Kyle wrote:
> Jeff Hobbs napisał(a):
>
> well i actually want it to run on windows platform (should have
> mentioned it earlier, sorry), so if you could elaborate more, and at
> last point me in the right direction i would be grateful


Look for how SetLayeredWindowAttributes is called in tk/win/tkWinWm.c.
Instead of LWA_ALPHA, if you use LWA_COLORKEY and specify an RGB color
that should be transparent, then you could do essentially what you want.
Combine it with a wm overrideredirect window, making it white where
white is the transparent color, anything you draw on that will be all
that you should see. More info at:

http://msdn.microsoft.com/library/e...wattributes.asp

--

Jeff Hobbs, The Tcl Guy, http://www.activestate.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com