#!/bin/wish /* { DEMO - Image Viewer lilwish (Lil+libpanel) demonstration app Mar 24 2020 (c) That Guy With The Hair Display image viewer. } */ Tk -new set filelist [rc ls -p i] set global filelist [split $filelist "\n"] set iconres 64x64 set message "click on listbox to display image" proc loadimg {lb b n} { local img local f set f [index $filelist $n] set img [tkicon i $f $iconres] if [expr $img == 0] { print "Could not load image" return } tkcfg .top.fl.img -image $img set x [imageinfo $img] set ires "$f - [index $x 5]x[index $x 6]x[index $x 2]" tkcfg .top.fx.msg -text "$f - [tksize i $f] " tkupdate force list } # # setres - Callback from radiobuttons to change image resoluton # proc setres { r lb} { if [streq $r fit] { set bb [config [tkwidget .top.fl.img] bbox] set x [expr [index $bb 3] - [index $bb 1]] set y [expr [index $bb 4] - [index $bb 2]] set r "${x}x$y" } set global iconres $r } /* { Build Toplevel Frame Use tkwidget overloading functions to define widgets }*/ group .top -side top -anchor nw -fill both frame .top.h -fill x label .top.h.l -text {An So It Begins!} frame .top.fx -side bottom -fill x frame .top.lbf -side left -fill Y frame .top.fl -side top -expand 1 label .top.lbf.xx -text {Listbox Header} listbox .top.lbf.lb -side left -fill y -var filelist -cmd "loadimg" scrollbar .top.lbf.sb -subwidget [wm id .top.lbf.lb] -width 20 -height 100 -side right -fill Y button .top.fl.img -text {I AM NOT AN IMAGE} -expand 1 label .top.fx.msg -side top -fill x -text $message -var message foreach {64x64 100x100 300x200 400x10 fit} { radiobutton .top.fx.res$i -text "$i " -side left -cmd "setres $i" } button .top.fx.quit -text " \[ QUIT \] " -side right -anchor right -cmd "evQuit bt.bq" tktoplevel .top tkupdate force eventloop 1000 puts "It's Bruce, Bruce, Bruuuce, Bruu ccccc eeee. Yeah is Trevor there? "