Hello from Cologne Germany, I want to get updated the content of the radiobutton during the execution of the code.
my @VehicleProgram=('AA','BB'); #if user selects $VehicleProgram=AA my @CrashMode=('12','13'); #if user selects $CrashMode=12 my @Load=('AA_121','AA_13','BB_12','CC_12','AA_122'); depending on $VehicleProgram and $CrashMode the radiobuton Load should contains only the relevant Values of @Load #Radiobutton Load (@LoadArrayRef) # should contain ONLY 'AA_121' and 'AA_122'
Below is the code which I am using. It seams, the button will be created during the initialization and does not get updated. It works when I create a new toplevel window for Load and destroy it after selection but I prefer to have all the buttons on same window.
Thank you in advance for your help. Cem
#!/usr/bin/perl -w use Tk; my @VehicleProgram=('AA','BB'); my @CrashMode=('12','13'); my @Drive=('lhd','rhd'); my @Side=('Driver','Passanger'); my @Dummy =('50','95','5'); my @Load=('AA_121','AA_13','BB_12','CC_12','AA_122'); @LoadArrayRef=@Load; $Program = 'undef'; $CrashMode = 'undef'; $Drive = 'undef'; $Side = 'undef'; $dummy = 'undef'; $Load = 'undef'; $Error ='no'; $font2='-adobe-courier-medium-r-normal--16-100-100-100-m-90-iso8859-2' +; 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 $w3 = $menubar->cascade(-label => 'Drive',-tearoff => 0); my $w4 = $menubar->cascade(-label => 'Side',-tearoff => 0); my $w5 = $menubar->cascade(-label => 'Dummy',-tearoff => 0); my $w6 = $menubar->cascade(-label => 'Load',-tearoff => 0); my $w11 =$menubar->Button(-label => 'CreateRun', -command => \&CreateRun,-state => 'disabled'); $menubar->Button(-label => 'Exit', -command => sub{exit}); my $sw3 = $mw->Frame(-relief => 'ridge', -bd => 2,-height=>'40')->pack(-side => 'top', -anchor => 'w', -expand => 0, -fill => 'both'); my $cm1=$sw3->Label(-text => " Comment: ", -font => "$font2")->pack(-side => 'left',-anchor => 'w'); my $cm2=$sw3->Entry(-textvariable => \$comment, -background => "white",-foreground => "black",-relief => 'ridge', -font => "$font2")->pack(-side => 'left',-anchor => 'w'); 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 (@Drive) {$w3->radiobutton (-label => "$i", -command => \&set_bg,-variable => \$Drive, -font => "$font2",-value => "$i")} foreach my $i (@Side) {$w4->radiobutton (-label => "$i", -command => \&set_bg,-variable => \$Side, -font => "$font2",-value => "$i")} foreach my $i (@Dummy) {$w5->radiobutton (-label => "$i", -command => \&set_bg,-variable => \$dummy, -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(-text => "$Drive", -font => "$font2")->pack(-side => 'left',-anchor => 'w'); $sw4->Label(-text => "$Side", -font => "$font2")->pack(-side => 'left',-anchor => 'w'); $sw4->Label(-text => "$dummy", -font => "$font2")->pack(-side => 'left',-anchor => 'w'); $sw4->Label(-text => "$Load", -font => "$font2")->pack(-side => 'left',-anchor => 'w'); $w11->configure(-state => 'active') if ($Program ne 'undef' and $CrashMode ne 'undef' and $Drive ne 'undef' and $Side ne 'undef' and $dummy ne 'undef' and $Load ne 'undef'); @LoadArrayRef=@Load; UpdateLoadArray (); } sub UpdateLoadArray { my (@new); foreach (@LoadArrayRef) { if ($_ !~ /$Program/) {next} if ($_ !~ /$CrashMode/) {next} print "$_\n"; push (@new,$_); } @LoadArrayRef=@new; print "-----\n"; print "Program:$Program CrashMode:$CrashMode\n"; foreach (@LoadArrayRef) {print "$_\n"} print "-----\n"; } sub CreateRun { }

In reply to PerlTK: update radiobutton content on code execution by cemmec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.