Version 18 of Shape

Updated 2019-12-27 04:13:30 by weiwu

Shape is an Extension written by Donal Fellows which allows arbitrarily shaped windows on X11 and Windows to be created. The latest release, Shape 0.4, was released in 2000. It supports X11 and Microsoft Windows only. http://www.cs.man.ac.uk/~fellowsd/tcl/shapeidx.html

To this day, there is no known way to create shaped windows across all of X11, Windows and OS X.

DKF: 27-Mar-2003 - It's on the Tk 9.0 Wishlist.

Windows

TkTrans is a Windows-specific alternative.


In a discussion on comp.lang.tcl it is shown that you can get a shaped window even with plain Tcl on windows. However I would only use it for a splash screen.

wm overrideredirect [toplevel .some] 1
wm geometry  .some 800x600+40+20
wm attribute .some -transparentcolor #C1C2C3
canvas .some.c -wid 800 -hei 600 -bg #C1C2C3 \
-bd 0 -relief flat -highlightthickness 0
pack .some.c -padx 0 -pady 0 -ipadx 0 -ipady 0
.some.c create oval 20 20 780 580 -width 1 -fill #ff0000
frame .some.c.w
pack [label .some.c.w.t -text "Bonjour! Tcl" -fg #C1C2C3]
.some.c create window 40 40 -window .some.c.w

RLE (2012-10-08): Note that the "-transparentcolor" option to wm attribute is documented as a Windows only feature (wm man page):

On Windows, the following attributes may be set.
...
-transparentcolor
Specifies the transparent color index of the toplevel. ...

OS X

tcltk-d: 2012-10-09 On MacOS10.6 wish V8.4

 # (set w .anytoplevel)
 $w conf -bg systemTransparent
 wm attribute $w -transparent 1

may work!

weiwu: it doesn't on my OS X Sierra but it also doesn't through an error (where on Linux it would error that "systemTransparent" is an unknown colour.

Linux

[TkZinc] used to support it. Now the project seems to have vanished.


Something like Shape needs to be combined with a 'drag and drop' extension to allow proper dragging of arbitrarily shaped objects from, e.g. a canvas or a text widget (where you might want to drag a non-rectangular block of text).

Does anyone have plans to really add proper 'drag and drop' support to Tk? Any TIPs in the pipeline?

MGS 2003/03/26 - I think the best bet may be TkDND