To find out what item the user double-clicked on, add something along the lines of:

$tree->bind('<Double-1>' => sub { print "Got:\n"; print " $_\n" for $tree->info('selection'); });

just after the line where you configure the -opencmd option. You'll have to modify the sub {...} to suit your purposes, of course.

As for showing the file icons, it's a little unclear exactly what you want. If you mean that you simply want a different icon for a file than for a directory, then you can simply change the image requested in the dyntree_adddir sub depending on whether the item being added tests as a directory or not (-d).

If, however, you mean that you want, say, a different icon for each different file type (eg, the way MS's Explorer shows different icons depending on the extension of the file), that is rather more difficult. First of all, you'll have to decide how you want to determine which file gets which icon. Then you need to decided where you want to get all those icons from (eg, do you want to try and extract them from the OS, or do you want to carry around a bunch of images files with your program). Once you've decided those things, then you can start figuring out how to add those icons in to the program.

bbfu
Black flowers blossom
Fearless on my breath


In reply to Re2: using TK tree or dirtree by bbfu
in thread using TK tree or dirtree by michaelg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.