Hi tamaguchi,

Once you have the left and right frames setup, figure out what kind of widget you want to display files in.  Easiest is probably a Text widget, into which you can write the filenames, one per line, with a tag configured on each one.  (You can use the file's name for the tag to guarantee each file has a unique tag name.)  You simply bind a subroutine to the tag for each filename, such that when you click on it, that subroutine gets invoked.

Although you "dont' ask for code", I'll provide you a very simple example of configuring tags for inserting text into a Text widget, as I hope that will help you get started:

use strict; use warnings; use Tk; my $mw = new MainWindow; my $tw = $mw->Text()->pack(-expand => 1, -fill => 'both'); foreach my $item (qw( item1 item2 item3 )) { my $tagname = $item; $tw->tagBind($tagname, "<Button-1>", sub { clicked_item($item) }); $tw->insert('end', $item, $tagname); $tw->insert('end', "\n"); } MainLoop; sub clicked_item { my ($item) = @_; print "You clicked on item $item!\n"; }

You may also want to change the cursor so as to get a visual clue when the mouse is over text that can be selected.  This can be a little tricky, so I'll explain it here.

What you need is a subroutine to change the cursor whenever the mouse is hovering over a given tag, and another to change the cursor back.  Hovering over a tag is an event called "<Any-Enter>", and moving away is called "<Any-Leave>".  You can create these anonymous subroutines (called $p_enter and $p_leave below), and then bind them to the tag the same way as you bound the named subroutine clicked_item.

Here's the full example:

use strict; use warnings; use Tk; my $mw = new MainWindow; my $tw = $mw->Text()->pack(-expand => 1, -fill => 'both'); my $p_enter = sub { $_[0]->configure(-cursor => 'hand2') }; my $p_leave = sub { $_[0]->configure(-cursor => 'xterm') }; foreach my $item (qw( item1 item2 item3 )) { my $tagname = $item; $tw->tagBind($tagname, "<Button-1>", sub { clicked_item($item) }); $tw->tagBind($tagname, "<Any-Enter>", $p_enter); $tw->tagBind($tagname, "<Any-Leave>", $p_leave); $tw->insert('end', $item, $tagname); $tw->insert('end', "\n"); } MainLoop; sub clicked_item { my ($item) = @_; print "You clicked on item $item!\n"; }

I hope that will help you to get started.

Update:  Separated the text insert into two lines, so that the tag only applies to the text, not to the rest of the blank line.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: TK question: navigating frames by liverpole
in thread TK question: navigating frames by tamaguchi

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.