in reply to GETTING the input from a cascading menu
As you can see from earlier posts, you haven't provided sufficient information for us to help you. I won't say any more about that; however, please read "How do I post a question effectively?" and "Short, Self-Contained, Correct Example" before posting again.
I suspect you're confusing Tk::Entry with the word "entry" used by Tk::Menu. From its doco (my emphasis):
"A menu is a widget that displays a collection of one-line entries ... There exist several different types of entries, ... Entries of different types may be combined in a single menu. Menu entries are not the same as entry widgets. In fact, menu entries are not even distinct widgets; the entire menu is one widget. ..."
You later wrote:
"I need to get the dirname from Tk::Enter so I can build a command line and execute it."
[Yes, you did write Tk::Enter. You need to be careful about that sort of thing.]
I think the following might form the guts of what you're attempting. It's fully functional as is. You'll need to get $dir into your command line, instead of displaying it in a label. Once you have the basic functionality working, add cosmetics (colours, fonts, borders, etc.).
#!/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;
See also: Tk and Tk::chooseDirectory.
— Ken
|
|---|