in reply to Re: PerlTK: update radiobutton content on code execution
in thread PerlTK: update radiobutton content on code execution
Cleaned codeHi zentara, thank you for your help. I will try to explain my problem. start script. Program-> chose AA CrashMode-> chose 12 > Now the Button Load should display only AA_121 and AA_122. Currently all Elements of the Array @Load are displayed. Thanks Cem
#!/usr/bin/perl use warnings; use strict; use Tk; my @VehicleProgram = ( 'AA', 'BB' ); my @CrashMode = ( '12', '13' ); my @Load = ( 'AA_121', 'AA_13', 'BB_12', 'CC_12', 'AA_122' ) +; my @LoadArrayRef = @Load; my $Program = 'undef'; my $CrashMode = 'undef'; my $Load = 'undef'; my $Error = 'no'; my $font2 = '-adobe-courier-medium-r-normal--16-100-100-100-m-90-iso88 +59-2'; my $sw4; my $comment; my $mw = MainWindow->new; my $toplevel = $mw->toplevel; my $menubar = $toplevel->Menu( -type => 'menubar' )->pack; my $w1 = $menubar->cascade( -label => 'Program', -tearoff => 0 ); my $w2 = $menubar->cascade( -label => 'Crash Mode', -tearoff => 0 ); my $w6 = $menubar->cascade( -label => 'Load', -tearoff => 0 ); my $sw3 = $mw->Frame( -relief => 'ridge', -bd => 2, -height => '40' )->pack( -side => 'top', -anchor => 'w', -expand => 0, -fill => 'both' ); foreach my $i ( @VehicleProgram ) { $w1->radiobutton( -label => "$i", -command => \&set_bg, -variable => \$Program, -font => "$font2", -value => "$i" ); } foreach my $i ( @CrashMode ) { $w2->radiobutton( -label => "$i", -command => \&set_bg, -variable => \$CrashMode, -font => "$font2", -value => "$i" ); } foreach my $i ( @LoadArrayRef ) { $w6->radiobutton( -label => "$i", -command => \&set_bg, -variable => \$Load, -font => "$font2", -value => "$i" ); } MainLoop; sub set_bg { $sw4->destroy if Exists( $sw4 ); $sw4 = $mw->Frame( -relief => 'ridge', -bd => 2, -height => '40' )->pack( -side => 'top', -anchor => 'w', -expand => 0, -fill => 'both' ); $sw4->Label( -text => "$Program", -font => "$font2" )->pack( -side => 'left', -anchor => 'w' ); $sw4->Label( -text => "$CrashMode", -font => "$font2" )->pack( -side => 'left', -anchor => 'w' ); $sw4->Label( -textvariable => \$Load, -font => "$font2" )->pack( -side => 'left', -anchor => 'w' ); @LoadArrayRef = @Load; UpdateLoadArray(); } sub UpdateLoadArray { my ( @new ); print "@LoadArrayRef\n\n"; foreach ( @LoadArrayRef ) { if ( $_ !~ /$Program/ ) { next } if ( $_ !~ /$CrashMode/ ) { next } print "$_\n"; push( @new, $_ ); } @LoadArrayRef = @new; print "-----\n"; print "new-> @new\n"; print "Program:$Program CrashMode:$CrashMode\n"; # update label thru textvariable $Load = join ' ', @new; foreach ( @LoadArrayRef ) { print "$_\n" } print "-----\n"; } sub CreateRun { }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: PerlTK: update radiobutton content on code execution
by zentara (Cardinal) on Feb 27, 2009 at 19:17 UTC | |
by cemmec (Initiate) on Feb 27, 2009 at 19:55 UTC | |
by cemmec (Initiate) on Mar 06, 2009 at 11:06 UTC |