Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to Change Defaults in Basic Tk Menu

by choroba (Cardinal)
on Aug 29, 2020 at 22:20 UTC ( [id://11121187]=note: print w/replies, xml ) Need Help??


in reply to How to Change Defaults in Basic Tk Menu

Imitate a click on the radio button before starting the main loop:
my $wrap = $menu->entrycget(3, '-menu')->entrycget(3, '-menu'); $wrap->invoke(0);

Update: Another option is to set the associated variable to the expected value:

my $wrap = $menu->entrycget(3, '-menu')->entrycget(3, '-menu'); my $word = $wrap->entrycget(0, '-value'); # 'word' ${ $wrap->entrycget(0, '-variable') } = $word;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: How to Change Defaults in Basic Tk Menu
by haj (Vicar) on Aug 30, 2020 at 00:08 UTC

    Note that for readability you can also use the labels instead of numerical indices:

    my $wrap = $menu->entrycget('View','-menu')->entrycget('Wrap','-menu') +; $wrap->invoke('Word');

    @roho: I don't know how choroba did it, but I found out that you've been using a method $more->menu and failed to find documentation for it. This made me curious, and I found that this method gets you the hardcoded menu from the Tk::Text widget, only that you don't get a chance to set the -wrap option for this widget. The rest was a matter of digging through this menu and the Tk docs...

      Thanks for the follow-up info haj. This was indeed quite obscure.

      "It's not how hard you work, it's how much you get done."

Re^2: How to Change Defaults in Basic Tk Menu
by roho (Bishop) on Aug 29, 2020 at 23:29 UTC
    Thank you choroba! I used your second option. It works perfectly. I searched but could not find anything remotely resembling the steps you laid out. How on earth (and from where) did you dig out those details? Thanks again.

    "It's not how hard you work, it's how much you get done."

      Experience with Tk, documentation of Tk::Menu, plus Data::Dumper and a few lines like
      print Dumper($menu->entrycget(0, '-menu')); print Dumper($menu->entrycget(0, '-menu')->entrycget(0, '-label'));

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-23 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found