in reply to TK question: navigating frames

Hi, I would use a listbox on the left, and text widget on the right. The only glitch is that a left click on a listbox is predefined to select an item, so I made a right-click to actually open the file.

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; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum