Hi Monks I have a single menubutton with few menuitems . My intention is whenever a single click on a menuitem its text for instance "supplier1" to be entered to the following textfield ($expenseentry) Thank You
use warnings; use Tk; my $mw = new MainWindow; $mw->geometry("400x400+200+0"); my $frm_name = $mw-> Frame(-relief=>'groove',-borderwidth=>5, -background=>'black')->pack(-side =>'top', -fill=>'x'); my $expensemb = $frm_name->Menubutton( -tearoff=> 0,-text=>"Eksodo", -menuitems=> [[ 'command' => "supplier 1", -command=> \&addtextfield], [ 'command' => "supplier 2" ], [ 'command' => "supplier 3" ], [ 'command' => "supplier 4" ]])->pack(-side=>'left',-anc +hor=>'nw'); my $costlabel = $frm_name -> Label(-text=>"Timh", -background => 'red') -> pack(-side=>'left', -anchor =>'nw', -padx =>70); my $frm_name2 = $mw -> Frame(-relief=> 'groove',-borderwidth => 5,-ba +ckground => 'black') ->pack(-side => 'top',-fill => 'x'); $expenseentry = $frm_name2->Entry(-width=> 10) -> pack(-side =>'left',-anchor =>'nw'); #sub addtextfield #sub addtextfield { #$val = $$expensemb->configure(-menuitems=> [ 'command' => "" MainLoop;

In reply to Tk - Menuitems -grab text by props

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.