Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: GUI issue

by zentara (Archbishop)
on Oct 18, 2011 at 12:47 UTC ( #932129=note: print w/replies, xml ) Need Help??

in reply to GUI issue

Your example code didn't run for us to easily modify, but here is an idea for reducing or eliminating the iterations. You can pass extra info to the sub in the callback, which will clearly identify which button was pressed. You can make a hash element unique to each radio button if you wanted, like a unique token, and pass that in to the callback.

Here is a simple example. For further help, make a small fully running code snippet for us to play with. Having to flesh out incomplete code examples, for testing, usually results in monks moving on to the next question.

#!/usr/bin/perl use Tk; my $mw = MainWindow->new; my $rb = 'first button'; my $rb1 = $mw->Radiobutton(-text => "Button One", -value => 'button1', -variable => \$rb, -command => [ \&showRB, \$rb, 1, 'man' ])- +>pack; my $rb2 = $mw->Radiobutton(-text => "Button Two", -value => 'button2', -variable => \$rb, -command => [ \&showRB, \$rb, 2, 'auto' ])->pack; MainLoop; sub showRB { #print "Arg list is @_\n"; #print "@_\n"; my ($state_ref, $button_num, $type) = @_; my $state = $$state_ref; print "$state $button_num $type\n"; $mw->messageBox(-title => 'Status', -type => 'OK', -message => "Status is :$state: $type button $bu +tton_num."); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: GUI issue
by harika123 (Initiate) on Oct 19, 2011 at 11:20 UTC

    Thanks zentara for your help....It really worked...Thanks alot

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932129]
[1nickt]: thezip use Path::Tiny. @paths = path("/foo")-> children; (Excludes "." and ".." automatically.)
[1nickt]: (Also takes a compiled regexp as an arg to filter the list)
[1nickt]: For multiple dirs use iterator(): $it = path("/foo")-> iterator; while ( my $path = $it->() ) {...}
[1nickt]: (also skips . and .. automatically, and follows subdirs if you set <c\>recurse => 1</c>
[1nickt]: $it = path("/foo")-> iterator(recurse => 1 );

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-03-28 18:45 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (339 votes). Check out past polls.