본문으로 바로가기

TkTrans

category 확장 패키지 (Extension Package) 2024. 12. 10. 09:44

홈페이지 : http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html

TkTrans는 Tk 이미지를 사용하여 직사각형이 아닌 탑 레벨 윈도우와 위젯을 만들 수 있는 Tcl/Tk 확장 패키지 입니다. 윈도우즈 전용입니다.

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
update

# 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

tktrans.zip
0.05MB

'확장 패키지 (Extension Package)' 카테고리의 다른 글

Plplotter widget 5.1.1  (2) 2024.12.10
OpTcl 3.0 build 10  (0) 2024.12.10
jacl 1.4.1  (0) 2024.11.21
TMCI - Tcl Media Control Interface  (0) 2024.11.21
Pad++ 0.9 : Zoomable User Interfaces  (0) 2024.11.21