Re: Image viewing - a different approach



ZB wrote:
Dnia 22.01.2008 Glenn Jackman <glennj@xxxxxx> napisał/a:

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

If I properly understood, it's a method for platform-independent "launch"
("run", "exec"... whatever) command. But my intention was somewhat
different: I would to create some kind of "link", which could be then
pack-ed anywhere in chosen toplevel - and such link, when clicked by the
user, would then be seen by OS as "shortcut to file"; exactly the same
kind of shortcut, as every Windows user has his desktop filled with.

You mean, something like the following?

proc link {path filename} {
button $path -text [file tail $filename] \
-command [list launch::file $filename] \
-borderwidth 0 \
-foreground blue \
-cursor hand2
return $path
}
link .link1 "c:/foo/bar/baz.gif"
link .link2 "c:/whatever.pdf"

It sounds like you're asking the toolkit to deliver something you can do yourself with just a handful of lines of code. Why does something like this need to be part of the core when it's so easy to do with what we already have?


--
Bryan Oakley
http://www.tclscripting.com
.


Quantcast