#!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new; $mw->geometry("400x400+0+0"); my $menu_f = $mw->Frame()->pack(-side=>'top',-fill=>'x'); my $menu_file = $menu_f->Menubutton (-text=>'File',-tearoff=>'false') ->pack(-side=>'left'); $menu_file->command(-label=>'Open', -command=> \&get_file); #other menu buttons shown here as examples ... #$menu_file->command(-label=>'Save', # -command=> \&save_log); #$menu_file->command(-label=>'Close', # -command=> \&close_log); #$menu_file->command(-label=>'Exit',-command=>\&exit_msg); sub get_file { my @types = (["Log files", [qw/.txt .log/]], ["All files", '*'], ); my $filepath = $mw->getOpenFile(-filetypes => \@types) or return(); print "$filepath selected\n"; return($filepath); } MainLoop;