Hi,
you need to invoke the chooseDirectory method from an other widget like this:
$dir = $main->chooseDirectory;
You missed to pass needed arguments too the dir_dialog. If you change the line 18 to
$filemenu->command(-command => sub{ dir_dialog($main) }, -label => "Get dir"); the dialog comes up. you also need to pass the second argument for $ent.