可以打开并查看图片,点击工具栏上 Previous 和 Next 按钮来浏览 前/下 一张。仅仅是一个例子,其它按钮和菜单未添加命令。
package require Ttk
package require Img
package require base64
package require BWidget
package require Thread
package require Ttrace
set icon(import) {
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAAAg1JREFUeNp8U0FME0EUfTM7s9AWkhKTpcSrePBkCB4gYAwHPXCQyEEk
wQs3z57VaEKIiVdveCEpBGoLBBBOYLh4NASORNGDaThQFNva7u74Z3bbbrXwmt/+nZn/+v6ft0wp
BY219fVT1/OSyvcRrGjojIEzBsbYyYOxMQcRmFr9peN9LqcuQz6fV5lsNv0vAW9iI3z5ekzxLYxj
szafTsNxHAwNDDzK5HILURIeFashhICUQejcHKIWqq6L7lQKw4ODE9mVlUytTkT0hASW7tfkvvLN
7/XeXiwtL9OzwtTkpFY7/j9BCIs3CCz6FIsl3OrvN1E/wyxcSMAtAV2viWxh0wGJatGv78s4R0J2
XEwgBDcK2mUMs6uvsPl5g26S11vknCNmt2N05t4iPU60bIFTQZuUpnjm8RQqbgWe75EjGIQlEW8j
8szaw9YElmVIAm0c5+UC7ve9aDrzYX8W4Xwb19gg4CYCMJyV8/W9ub0nmH6XxO/KKRAOuqGgtkDS
dQtBOcN59Sww06enmB5+i2QihZ9/vpu9JgV6OMEMeI3LtOOyksn3f2xj4+ANxvueoeQVDH2TAnLb
L3JYpzaLdl5cJGiQNpjw8Xr3Lpyuqzg82cbhzhaudPaQFwJiVnsH6OpuGu9EMPL89mLc7rgGxcJ/
VMbynFK37H7cfLl1J0qAFrhBEUNrFKj26K8AAwCgT9EiWWDEHQAAAABJRU5ErkJggg==
}
set icon(export) {
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAAAgVJREFUeNp8k0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EtHHYrH4yrZt6LqOMAxxSSfag5Zl
PWLmK9M0zXK5DCICEQEABoMBmBnMDCEEhBBg5t+9Xu8hSSnRaDSe67r+uVKp6IVC4XY2vp3uLpGU
ElJKZFmGyWSCfr9PSq1W+2QYxstSqQQiwnq9Pvy2j7sEaZoiy7KDLgqAP0EQyOl0SqqqQtd1aJoG
VVWhKMqh5X3xzc0NttvtQRd2XfetlLJJRH+TJEEYhvB9H0EQIAxDRFGEKIqw2+0QxzGSJEEcx/8J
AMB13a8AygC+pGkKIgIzQ1EU5HI5LBYLLJdLrFYrbDabvQ4/j7YAAPV6nZj5tRDifT6fVwzDgKZp
mM1mGI1GdGqNR0Yaj8fScZwPaZo+9Tzvl+/7IKKLPjjpRMdxvkspTc/zrubz+UWCw27PhWVZL2zb
vj6H033P+R+JCADzIQVFMAAAAABJRU5ErkJggg==
}
proc main { } {
global lab icon
set w .
wm title $w "Example - Toolbar,Menu"
set f [ frame $w.toolbar -relief ridge -borderwidth 1 ]
pack $f -side top -anchor nw -fill x
set sw [ ScrolledWindow .sw ]
pack $sw -side top -anchor nw -fill both -expand 1
set sf [ ScrollableFrame .sf -bg black ]
$sw setwidget $sf
set f2 [ $sf getframe ]
foreach val [ array names icon ] {
set $val [ image create photo -data $icon($val) ]
ttk::button $f.$val -image [ subst $$val ] -compound center -style Toolbutton
}
foreach separator { sp1 sp2 sp3 sp4 } {
ttk::separator $f.$separator -orient vertical
}
$f.open config -command "openFile"
$f.previous config -command "previous"
$f.next config -command "next"
$f.about config -command "About"
pack $f.open -side left -padx 2
pack $f.save -side left -padx 2
pack $f.sp1 -side left -ipady 7 -padx 2
pack $f.import -side left -padx 2
pack $f.export -side left -padx 2
pack $f.sp2 -side left -ipady 7 -padx 2
pack $f.settings -side left -padx 2
pack $f.sp3 -side left -ipady 7 -padx 2
ttk::checkbutton $f.b5 -image $detail -compound center -style Toolbutton
pack $f.b5 -side left -padx 2
pack $f.exportLog -side left -padx 2
pack $f.clear -side left -padx 2
pack $f.sp4 -side left -ipady 7 -padx 2
pack $f.help -side left -padx 2
pack $f.about -side left -padx 2
pack $f.previous -side left -padx 2
pack $f.next -side left -padx 2
set lab [ label $f2.lab1 -bd 0 -justify center -bg black ]
pack $f2.lab1 -padx 2 -anchor nw
menu .menubar -tearoff 0
. config -menu .menubar
foreach val { File View Settings About } {
set menu($val) [ menu .menubar.m$val -tearoff 0 ]
.menubar add cascade -label $val -menu $menu($val) -underline 0
}
$menu(File) add command -label "Open..." -command "openFile" -underline 0 -image $open -compound left -accelerator "Ctrl+O"
$menu(File) add command -label "Save..." -underline 0 -image $save -compound left -accelerator "Ctrl+S"
$menu(File) add command -label "Import..." -underline 0 -image $import -compound left -accelerator "Ctrl+I"
$menu(File) add command -label "Export..." -underline 0 -image $export -compound left -accelerator "Ctrl+E"
$menu(File) add separator
$menu(File) add command -label Exit -command exit -underline 1 -image $exit -compound left
$menu(View) add check -label "Aways on Top"
$menu(View) add cascade -label "Zoom" -menu $menu(View).zoom
$menu(View) add command -label "Workwrap"
$menu(View) add command -label "Back" -command "previous" -image $previous -compound left
menu $menu(View).zoom -tearoff 0
$menu(View).zoom add radio -label "Zoom Out" -underline 0
$menu(View).zoom add radio -label "Zoom In" -underline 0
$menu(Settings) add command -label "Preferences..." -underline 0 -image $settings -compound left -accelerator "Ctrl+P"
$menu(About) add command -label Help -underline 0 -image $help -compound left
$menu(About) add separator
$menu(About) add command -label About -command "About" -underline 0 -image $about -compound left
bind . "openFile"
bind . "next"
bind . "previous"
bind . {
if { %D >= 0 } {
previous
} else {
next
}
}
focus -force $w
}
proc SelectNextImageFrame {w interval} {
global animationCallbacks
catch { set animationCallbacks [ after $interval SelectNextImageFrame $w $interval ]
set image [ $w cget -image ]
set idx -1
scan [ $image cget -format ] "GIF -index %d" idx
if {[catch {
$image config -format "GIF -index [ incr idx ]"
}]} then {
$image config -format "GIF -index 0"
}} result
}
proc animateLabelImage {w interval} {
global animationCallbacks path
catch { set animationCallbacks [ after $interval SelectNextImageFrame $w $interval ]} result
trace variable path w ReadOnlyTrace
}
proc ReadOnlyTrace { varName index op } {
global animationCallbacks
catch {
after cancel $animationCallbacks
unset animationCallbacks
} result
}
proc openFile {{file ""}} {
global lab path
if { $file == "" } {
set types {
{{Image Files} {*.jpg;*.gif;*.bmp;*.png;*.pcx;*.ico;*.tiff;*.raw;*.ppm} }
}
set file [ tk_getOpenFile -parent . -title "Open image file" -filetypes $types ]
}
set path $file
set err [ catch { set bd [ open $file { RDWR BINARY } ]} result ]
if { $err != 0 } {
return
}
set data [ read $bd nonewline ]
close $bd
set imageData [ base64::encode $data ]
set image [ image create photo -data $imageData ]
$lab config -image $image
if {[ string tolower [ file extension $file ]] == ".gif" } {
animateLabelImage $lab 100
}
}
proc previous { } {
global path
if {![ info exists path ] || $path == "" } {
return
}
set list [ glob [ file dir $path ]/{*.jpg,*.gif,*.bmp,*.png,*.pcx,*.ico,*.tiff,*.raw,*.ppm}]
set pos [ lsearch $list $path ]
if { $pos != 0 } {
incr pos -1
} else {
set pos end
}
set path [ lindex $list $pos ]
openFile $path
}
proc next { } {
global path
if {![ info exists path ] || $path == "" } {
return
}
set list [ glob [ file dir $path ]/{*.jpg,*.gif,*.bmp,*.png,*.pcx,*.ico,*.tiff,*.raw,*.ppm}]
set pos [ lsearch $list $path ]
if { $pos != [ expr {[llength $list ] - 1}] } {
incr pos 1
} else {
set pos 0
}
set path [ lindex $list $pos ]
openFile $path
}
proc About { } {
set msg " \n This is an example for toolbar and menu.\n\
It also can preview image!\n\n\
Tcl/tk application.\n\
Author\t: Andy_Wen\n\
Email\t: [email protected]"
tk_messageBox -type ok -title "About" -icon info -message $msg
}
proc popErr { str } {
tk_messageBox -type ok -title "Error" -icon error -message "$str"
}
main
if { [ lindex $argv 0 ] != "" } {
openFile [ lindex $argv 0 ]
}