Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2018-03-25 02:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (300 votes). Check out past polls.