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$..$/
|