From: Kyle on
hi,
as a tutorial project i tried to create a simple digital clock (which is
pretty easy task), however i wanted it to look cool (:

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)

code goes below

proc every { ms body } {
eval $body
after $ms [list every $ms $body]
}

proc dragStart {windowX windowY} {
set ::DragHoldPosition(x) $windowX
set ::DragHoldPosition(y) $windowY
}

proc dragTo {screenX screenY} {
set positionX [expr { $screenX - $::DragHoldPosition(x) }]
set positionY [expr { $screenY - $::DragHoldPosition(y) }]
wm geometry . [winfo width .]x[winfo height .]+$positionX+$positionY
}

bind . <Button-1> { dragStart %x %y }
bind . <Button1-Motion> { dragTo %X %Y }
bind . <Button-2> { destroy . }

pack [label .lab -textvariable timevar -font "ansi 54 bold" -foreground
#aa66ff]

wm overrideredirect . 1
wm attributes . -alpha 0.5 -topmost 1
every 500 {set ::timevar [clock format [clock sec] -format %H:%M:%S]}
From: Jeff Hobbs on
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 cool (:
>
> 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/
From: Uwe Klein on
Jeff Hobbs wrote:
> 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 cool (:

> 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
From: Kyle on
Jeff Hobbs napisa�(a):
> 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 cool (:
>>
>> 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.
>

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
From: Uwe Klein on
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