Friends (and strangers :) ),
I'm trying my hand at writing a perl-tk app, mostly for the shere fun of learning it, but have hit a stumbling block that I could use some advise on. My app is pulling in data that I'd like to display in a column/row format, allowing the user to simply double click the row they want to launch a new window that does some more fancy work/processing. I like the way Tk::HList looks, and have kludged it to do the job I want, but I'm wondering if there's a better way, or if I'm perhaps not using it correctly (I've read the pods, I've abused the widgets demo where applicable, and I don't have the resources to purchase "Mastering Tk" atm).

Right now, I have a code block like:

my $hlist = $mw->Scrolled(qw/HList -columns 3 -width 70 -command main::launch_win/)->pack(qw/-expand yes -fill both/);
which works, albeit in an ugly fashion. Through newbie experimentation I see that it passes the $entryID to my sub, and I've cobbled together what I believe to be a bad hack that associates the $entryID to a key in a hash, from which I can pull the relevant pieces of data to determine which row was hit and move forward. But is there a better way? The ideal would be to double click a row and pass it a specific piece of data rather than relying on the $entryID pass - am I doing this wrong? For those that wonder, I've tried using $hlist->configure(-command => mysub($whatiwant)), but this resulted in the desired command being run immediately for every row returned (not desirable when the number of rows can be between 1 and a really really large number).

I confess that my thinking is a little too linear at times, so I don't immediately grok how to declare the command prior to having the (randomly) generated data available. Is there perhaps a better way to give the display I want with the functionality I need than by using Tk::HList?

Thank you all in advance for your time and thoughts.

z3d



"I have never written bad code. There are merely unanticipated features."

In reply to TK::HList the best solution? by z3d

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.