use warnings; use strict; use Tk; my $mw = MainWindow->new (-title => "editor"); my $text = $mw->Scrolled ('Text', -font => 'normal', -wrap => 'word', -scrollbars => 'e',); $text->pack (); $mw->Button (-text => "open file", -command => \&openFile)->pack (); MainLoop (); sub openFile { my @filetypes = ( ['Text', '.txt', 'TEXT'], ['Text', '.txt', 'TEXT'], ); my $currentFile = $text->getOpenFile (-defaultextension => '.txt', -filetypes => \@filetypes); }