icoview2

Richard Suchenwirth 2004-10-01 - After I posted icoview, kroc hinted me to the pure-Tcl ico extension in Tklib. This can also read (and write!) Windows icons from .exe and .dll files, and contains the ico::Show displayer, which renders the found images - in a slightly surprising way, as it packs a scrolled window under ., without having been told so, and adds a labelframe for each shown file.

WikiDbImage icoview2.gif

So here's my tiny wrapper around ico::Show, which just contributes an entry for the file name, and a Select (...) button which brings up a file selector:

package require Tk
package require ico 0.3

pack [frame .f] -fill x
pack [button .f.b -text ... -command select] -side right
pack [entry .f.e -textvariable filename -width 60] \
    -fill x -expand 1 -side left
bind .f.e <Return> {ico::Show $filename}
set ::dir [file dir [info script]]
proc select {} {
    set fn [tk_getOpenFile -initialdir $::dir -f {
        {"All Icons" .exe} {"All Icons" .ico} {"All Icons" .dll}
        {Exe .exe} {DLL .dll} {Icon .ico} {"All files" *}}]
    if {$fn ne ""} {
        set ::dir [file dir $fn]
        set ::filename $fn
        ico::Show $fn
    }
}
select

bind . <Escape> {exec wish $argv0 &; exit}

MG Oct 2nd 2004 - Edited very slightly so that the tk_getOpenFile has an option that shows .exe, .dll and .ico files all at once, so you can view all the valid "icon" files without all the spam of viewing *.*.

Eugene 2011 February 26 - Seems that ::ico::Show isn't available anymore in ico package version 1.0.5 (the latest one teacup delivered me).