P.S. I see you want to draw figures on the right, so make it a canvas and do what you need to do.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = Tk::MainWindow->new( -title => 'Left-click -> select ... Righ +t-click -> view' ); my $frame = $mw->Frame()->pack(); my @files = get_sub_dirs('.'); my $lb = $frame->Scrolled('Listbox', -listvariable => \@files, -scrollbars => 'osoe', #only if needed )->pack(-side => 'left', -fill=>'y',-expand =>1); my $text = $frame->Scrolled('Text', -scrollbars => 'osoe', #only if needed )->pack(-side => 'right'); $lb->bind( '<ButtonPress-3>', [ \&view_it, Ev('@') ] ); MainLoop; sub view_it { my ( $lb, $xy ) = @_; $lb->selectionClear( 0, 'end' ); my $index = $lb->index($xy); my $file; if ( defined($index) ) { $lb->selectionSet($index); $file = $lb->get($index); $text->delete('1.0','end'); #clear out old file my $buf; open (FH,"< $file"); read( FH, $buf, -s FH ); close FH; $text->insert('end', $buf); } } ################################################################## sub get_sub_dirs { my $dir = shift; opendir my $dh, $dir or die "Error: $!"; my @files = grep !/^\.\.?$/, readdir $dh; closedir $dh; @files = grep ! -d, @files; return @files; }
In reply to Re: TK question: navigating frames
by zentara
in thread TK question: navigating frames
by tamaguchi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |