Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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


Comment on Re: GUI issue
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-08-23 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls