Fellow Monks,

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.