Re: Image viewing - a different approach



At 2008-01-22 12:49PM, "ZB" wrote:
And I'm looking for more general, and - at the same time - "automatic"
solution. If one could make such "shortcut", one can then rely just on the
OS's default file associations. Wouldn't it be smarter? And you don't care,
what kind of file it is: whether it is JPG-image, or PDF-doc, or just plain
TXT-file - all the needed viewers are launched by OS, where some
associations (hopefully) have been made already.

Here's one approach (untested):

namespace eval launch {
switch -glob -- $::tcl_platform(os) {
Darwin { set start_cmd open }
"Windows *" { set start_cmd start }
default {
# need more expertise here...
error "don't know how to launch a file on os $::tcl_platform(os)"
}
}
variable launch_cmd [auto_exe*** $start_cmd]
}
proc launch::file {filename} {
variable launch_cmd
eval exec [list $launch_cmd $filename &]
}

launch::file myimg.jpg



--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.