I have been making some changes to an in house test program. This new page presents the user with the ability to select a license option and to set the serial number of the unit as well as identify the unit by blinking it. I am having problems with:
1. When the blink button is pressed i want the serial number of that unit to get focus.
2. When the bar code scanner (USB) enters values into the labentry I want to cut the trailing /n and give focus to the next serial number box.
3. Lastly once it attempts to continue i want to validate that each serial is 15 char's long then write it to a file on the server.
sub createLicenseWindow { my $mins = int(8); #waittime in minutes my $waittime = int($mins * 60); #wait in seconds my @serailset; my $mainwindow = MainWindow->new(); $mainwindow->title("License Units"); $mainwindow->configure(-background=> 'wheat'); my $center = $mainwindow->Frame->grid(); $center->configure(-background=> 'wheat'); $center->Label(-text=>"Select license option to set on unit. New f +eature.\n\nWill automatticly continue after $mins minutes.", -backgro +und=>'tan', -foreground=>'green', -font=>['courier', '14', 'bold'])-> +grid(-row=>0, -column=>0, -columnspan=>2, -sticky=>'ew'); my $lic_frame = $center->Scrolled('Frame', -scrollbars=>'e', -heig +ht=>'300')->grid(-row=>1, -column=>0, -columnspan=>2); my $lic_grid = $lic_frame->grid(); $lic_grid->configure(-background=> 'wheat'); my @serailEnt; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]->{sys +tem}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$count] +; my $serail = \$serialEnt[$count]; my $bgcolor; if ($count % 2 == 0) { $bgcolor="LemonChiffon"; } else { $bgcolor="cornsilk"; } $lic_grid->Label(-text=>"IP: ".$system->{ip}->[0], -background +=>$bgcolor."1")->grid(-row=>$count, -column=>0); $serail = $lic_grid->LabEntry(-label=>"Serial: ", -background= +>$bgcolor."2", -textvariable=>\$system->{serial}->[0], -labelPack=>[- +side=>'left', -anchor=>'w'])->grid(-row=>$count, -column=>1); $lic_grid->BrowseEntry(-label=>"Set License: ", -background=>$ +bgcolor."3", -variable=>\$system->{license}->[0], -choices=>\@lic_opt +ions)->grid(-row=>$count, -column=>2); my $blink = $lic_grid->Button(-text=>"Blink Unit", -background +=>$bgcolor."4", -command=>sub { if ($system->{raidtype}->[0] =~ m/software/i or $system->{ +raidtype}->[0] =~ m/unknown/i) { qx"wincuri 2 $system->{ip}->[0] \"/usr/AmiNas/cli blin +k -t ld -l /dev/md255 raid\""; } if ($system->{raidtype}->[0] =~ m/hardware/i or $system->{ +raidtype}->[0] =~ m/unknown/i) { qx"wincuri 2 $system->{ip}->[0] \"/usr/AmiNas/cli blin +k -t ld -l /dev/sda raid\""; } $serail->focus; })->grid(-row=>$count, -column=>3); if ($system->{raidtype}->[0] =~ m/none/i) { $blink->enabled = 0; } } for (my $count = 0; $count < @serailEnt; $count++) { my $serail = \$serialEnt[$count]; $serail->bind('<KeyPress>' => sub{ print "Key pressed for serial $count\n"; my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$co +unt]; my $nextserail = \$serialEnt[$count+1]; $system->{serial}->[0] =~ s/\n//g; if (length($system->{serial}->[0]) >= 15) { $nextserail->focus; } }); } $center->Button(-text=>"Continue", -background=>'tan', -command=>s +ub { my $allset = 2; my $message = ""; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]-> +{system}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$co +unt]; if ($system->{serial}->[0] eq "") { $allset = 0; } elsif (length($system->{serial}->[0]) ne 15) { $message .= "Serial number ".$system->{serial}->[0]." +is ".length($system->{serial}->[0])." charaters\n"; $allset = 1; } elsif (length($system->{serial}->[0]) eq 15) { my $set = 1; foreach my $alreadydone (@serailset) { if ($system->{ip}->[0] eq $alreadydone) { $set = 0; } } if ($set == 1) { qx"wincuri 2 ".$system->{ip}->[0]." \"echo '".$sys +tem->{serial}->[0]."' > /etc/itxserial\""; push(@serialset, $system->{ip}->[0]); } } } if ($allset == 1) { $mainwindow->messageBox(-message=>"Serial numbers must be +15 charaters long\n\n$message", -title=>"Invalid Input"); } elsif ($allset == 2) { $waittime = -1; $mainwindow->destroy; } })->grid(-row=>2, -column=>0, -columnspan=>2, -sticky=>'ew'); $center->LabEntry(-label=>"Auto Continue in: ", -background=>'tan' +, -textvariable=>\$waittime, -labelPack=>[-side=>'left', -anchor=>'w' +])->grid(-row=>3, -column=>0); $center->Button(-text=>"Stop Timer", -background=>'tan', -command= +>sub {$waittime = -1;})->grid(-row=>3, -column=>1); my $timer = $mainwindow->repeat(1000, sub{ if ($waittime == 0) { my $allset = 1; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]-> +{system}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$co +unt]; if ($system->{serial}->[0] eq "" or length($system->{seria +l}->[0]) ne 15) { $allset = 0; } elsif (length($system->{serial}->[0]) eq 15) { my $set = 1; foreach my $alreadydone (@serailset) { if ($system->{ip}->[0] eq $alreadydone) { $set = 0; } } if ($set == 1) { qx"wincuri 2 ".$system->{ip}->[0]." \"echo '".$sys +tem->{serial}->[0]."' > /etc/itxserial\""; push(@serialset, $system->{ip}->[0]); } } } if ($allset == 1) { $waittime = -1; $mainwindow->destroy; } else { $waittime = -1; licenseEmail(); } } elsif ($waittime > 0) { $waittime--; } }); }

In reply to tk bind and widgets stored in array by glenn

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.