I'm using activestate perl on windows 2000, and I've just started to learn Tk, so apologies if this is an idiot question. I can't seem to make the underline work for the topmost item in the menu, in this case I get 'Menu' when I should be getting 'Menu'. Works fine for all the othe bits of the menu. I've included an example script below, but for the life of me I can't spot what I'm doing wrong. Is this just an issue with Tk on Windows platforms? or can I change the script below to get it working.
I'd appreciate your thought on this,
Martymart
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw=MainWindow->new; $mw->title('Menu Test'); my $menubar=$mw->Menu(-type=>'menubar'); $mw->configure(-menu=>$menubar); my $menu=$menubar->cascade(-label=>'~Menu'); my $menu_file=$menu->cascade(-label=>'~File', -tearoff=>0,); $menu_file->command( -label=>'~Open', -accelerator=>'Control+o', -command=>[\&print_it, 'Open']); $menu_file->command( -label=>'~Save', -accelerator=>'Control+s', -command=>[\&print_it, 'Save']); my $menu_edit=$menu->cascade(-label=>'~Edit'); $menu_edit->command( -label=>'C~ut', -accelerator=>'Control+x', -command=>[\&print_it, 'Cut']); $menu_edit->command( -label=>'~Copy', -accelerator=>'Control+c', -command=>[\&print_it, 'Copy']); my $exit=$mw->Button(-text=>'Exit', -command=>[$mw=>'destroy']); $mw->bind('<Control-o>',[\&print_it, 'Open']); $mw->bind('<Control-s>',[\&print_it, 'Save']); $mw->bind('<Control-x>',[\&print_it, 'Cut']); $mw->bind('<Control-c>',[\&print_it, 'Copy']); $exit->pack; MainLoop; sub print_it{ my $name=ref($_[0]) ? shift : ''; my $message=shift; print "message: '$message' ...\n"; }
In reply to Tk menu underline prob by martymart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |