#!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = Tk::MainWindow::->new(); my $dir = ''; my $menu_F = $mw->Frame()->pack(-fill => 'x'); my $label_F = $mw->Frame()->pack(-fill => 'both', -expand => 1); $label_F->Label(-textvariable => \$dir)->pack; my $menutop = $menu_F->toplevel(); my $menubar = $menutop->Menu(-type => 'menubar'); $menutop->configure(-menu => $menubar); my $file_menu = $menubar->Cascade( -label => 'File', -tearoff => 0, -menuitems => [ [ Button => 'Get Dir', -command => sub { $dir = $mw->chooseDirectory; }], [ Button => 'Exit', -command => sub { exit } ], ], ); MainLoop;