The problem is that the *first* image displayed always seems to be the
default image. It's as if tablelist can't determine the correct image
type on the first image. Subsequent images are displayed correctly.
My code below uses a directory/folder image as the default, so the
initial displayed image is always a folder--even if it's a file. But the
kind of image doesn't really matter--in other versions of this code, the
default was a generic "document" image, which would display even if the
first file listed was an .html or .pdf file (which I do have correct
images for).
I don't know if this is a bug in tablelist or an issue with how I'm
laying out my code. Any advice is appreciated.
Here's the code to get my image:
proc getImage {filename} {
if {[file isfile $filename] } {
if {[lsearch [image names] [file extension $filename] ]<=0} {
set listphoto "file-generic"
} else {
set listphoto [file extension $filename]
}
} else {
set listphoto folder
}
}
Here's the code to display the directory contents (based on glob
-directory . -nocomplain):
$w.right.list insert end [list $name $type $owner $size $date]
$w.right.list columnconfigure 3 -align right
$w.right.list columnconfigure 4 -align right
# $w.right.list columnconfigure [list 0 1 2 3 4] -align right
foreach col {0 end} {
$w.right.list cellconfigure $col,0 -image [fileicons::getImage $item]
#puts $cellimage
}
}
--
Kevin Walzer
Poetic Code
http://www.kevin-walzer.com
Take a closer look at the lines
if {[lsearch [image names] [file extension $filename] ]<=0} {
set listphoto "file-generic"
According to this code snippet, listphoto will be set to "file-generic"
not only if [file extension $filename] is not among the elements of
[image names], but also if it is the first element of that list. I
suspect that this was not your intention; to get it right, replace the
"<=0" with "<0".
--
Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de
And it is cases like this that caused 8.5 to have an 'in' expr operator.
In 8.5, you would write:
if {[file extension $filename] ni [image names]} { ...
(of course, the user code required negation).
--
Jeff Hobbs, The Tcl Guy, http://www.activestate.com/