Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks
I am trying to modify my script below and add a Tk Checkbox to my pop-up menu. Unfortunately I am not able to do it. Somebody can help?
#use strict; use warnings; use Tk; my $mw = tkinit(); my $CkAutomaticBackUp; my $b1 = $mw->Button( -text => "Hello", ); $b1->grid(-row => 0, -column => 1,); Popup($mw, $b1); $mw->MainLoop; sub Popup{ my ($mw, $obj) = @_; my $menu = $mw->Menu(-tearoff=>0, -menuitems=>[ [command=>"Something", -command=>[sub {print "Hello"}, $obj,]], #[checkbutton=>(-label =>"Prompt for automatic backup",-variable=> +\$CkAutomaticBackUp,-onvalue=>'1', -offvalue=>'0', -compound => 'left +'), -command=>[sub {print "$CkAutomaticBackUp"}, $obj,]], ]); $obj->menu($menu); $obj->bind('<ButtonPress>', ['PostPopupMenu', Ev('X'), Ev('Y'), ]) +; return $obj; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Add Tk checkbox to popup menu
by choroba (Cardinal) on Jan 31, 2018 at 18:49 UTC | |
by Anonymous Monk on Jan 31, 2018 at 19:15 UTC |