You are here


admin의 아바타
첨부 파일파일 크기
Image icon 5.png49.83 KB
Image icon 6.png126.91 KB
Package icon tktrans.zip55.7 KB

홈페이지 :

윈도우즈 전용입니다.

TkTrans is an Tcl/Tk extension that allows Tk to create true non-rectangular toplevel windows and widgets using any Tk image. On request the image is scanned and a inverse mask is generated from bright purple pixels (r=255, g=0, b=255). This is done by addition of two new commands:

tktrans::settoplevel window ?tk_image?
tktrans::setwidget window ?tk_image?

The following picture is of a canvas with an image item overlayed by an imaged button (the squiggly yellow link and red start):

With TkTrans, this becomes:

The source for the above is as follows:

# load the library
load tktrans

# create the two images
image create photo image1 -file test.gif
image create photo image2 -file test2.gif

# perform code to remove window decorations
# and bind in drag functionality
wm overrideredirect . 1

bind .  {
    set wx [winfo rootx .]
    set wy [winfo rooty .]
    set X %X; set Y %Y

bind .  {
    set dx [expr %X - $X]
    set dy [expr %Y - $Y]
    set nx [expr $wx + $dx]
    set ny [expr $wy + $dy]
    wm geometry . [join "+ $nx + $ny" {}]

# very important to do this just in case any Tk windows have not been created as yet

# now make the toplevel transparent according to the first image
tktrans::settoplevel . image1

# make a canvas and place the image item and button 
canvas .c
pack .c
.c create image 0 0 -image image1 -anchor nw

button .b -image image2 -highlightthickness 0 -relief flat -bd 0
.c create window 100 90 -window .b

# make the button transparent according to image2
tktrans::setwidget .b image2