http://www.perlmonks.org?node_id=1021198

ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I have a scrolled widget in my Perl Tk code. How can I introduce a callback just to check the -wrap value of it and take some action accordingly.

Following is just a snippet of my code :

use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->geometry("200x200"); my $frame = $mw->Frame()->pack; my $textbox = $frame->Scrolled('Text', -scrollbars => 'soe', -foreground => 'blue', -background => 'white', -wrap => 'none', )->pack; $textbox->insert('end', "This is scrolled widget.\nThis is scrolled wi +dget.This is scrolled widget"); MainLoop;


I want the callback to be called when I click RightMouseButton > View > Wrap on the scrolled frame and change the Wrap to something.
Please help. Thanks.
My callback should be like below

sub func { my $wr = $textbox->Subwidget('scrolled')->cget(-wrap); if ($wr =~ /\bnone\b/) { # do something } else { # do something else }