以下是大概的 TreeCtrl code
$tree state define HOVER $tree state define OPENW $tree state define OPENE $tree column create -tag cIcon $tree column create -tag cName -expand 1 $tree element create elemIcon image -image [$ibox get favicon-wretch] $tree element create elemName text -justify left $tree gradient create grdHover -steps 4 -stops {{0.0 white} {1.0 #ebf3fd}} -orient vertical $tree element create elemRect rect -fill [list grdHover HOVER] $tree element create elemRectOutline rect -rx 1 -outline [list #b8d6fb HOVER] \ -open [list w OPENW e OPENE] -outlinewidth 1 $tree element create elemBorder rect -outline "#e2e3e3" -open nws -outlinewidth 1 $tree element create elemBorderS rect -outline "#ffffff" -open nws -outlinewidth 1 # column icon set sty [$tree style create styIcon -orient horizontal] $tree style elements $sty {elemRect elemBorder elemBorderS elemRectOutline elemIcon} $tree style layout $sty elemRect -detach 1 -padx {2 0} -iexpand xy $tree style layout $sty elemRectOutline -detach 1 -iexpand xy $tree style layout $sty elemBorder -detach 1 -iexpand y -padx {27 0} $tree style layout $sty elemBorderS -detach 1 -iexpand y -padx {28 0} $tree style layout $sty elemIcon -padx {6 2} -pady {2 3} -iexpand ns # column name set sty [$tree style create styName] $tree style elements $sty {elemRect elemRectOutline elemName} $tree style layout $sty elemRect -detach yes -padx 0 -iexpand xy $tree style layout $sty elemRectOutline -detach yes -iexpand xy $tree style layout $sty elemName -padx 6 -pady {2 3} -squeeze x -expand ns set nsList [list moko wretch pchome pixnet xuite yam] foreach i $nsList { set item [$tree item create -parent 0] $tree item style set $item 0 styIcon 1 styName $tree item element configure $item 0 elemIcon -image [$ibox get favicon-$i] $tree item element configure $item 1 elemName -text $i } $tree item state forcolumn all 0 "OPENE" $tree item state forcolumn all 1 "OPENW"目前還遇到一個難題,就是沒有辦法做出 menu 陰影效果。
我覺得做個 menu 還拉 treectrl 進來的成本太高了,且有不少效果和功能還是沒辦法做得很好,最好是有 ttk::menu 之類的 widget,不過這又得從底層開始寫... 話說最近寫 wget 有不少心得找不到人分享很悶啊 XD
回覆刪除有些東西不適合公開講啦 XD
回覆刪除