$defineSerialsWindow = new MainWindow; $defineSerialsWindow->title ("select Serial(s)"); $defineSerialsWindow->geometry("1300x1000"); $defineSerialsWindow->resizable( 1, 1 ); my $img_icon = $defineSerialsWindow->Photo(-file=>$current_folder."\\img\\".'logo_ux.png'); $defineSerialsWindow->Icon(-image=>$img_icon); #scrollbar, because the window defineCustomerWindow is to small for showing all entries my $pane = $defineSerialsWindow->Scrolled('Pane', Name => 'Button_Window', -scrollbars => 'soe', -sticky => 'we', -gridded => 'y' ); #all labels and checkboxes are anchored at the new widget $pane to add a scrollbar my $label_selectAll_serials = $pane->Label (-text => 'select all'); my $checkbox_selectAll_serials = $pane->Checkbutton ( -command => \&select_all_serials, -variable => \$select_all_serials); $checkbox_selectAll_serials->deselect(); my $label_deselectAll_serials = $pane->Label (-text => 'deselect all'); my $checkbox_deselectAll_serials = $pane->Checkbutton ( -command => \&deselect_all_serials, -variable => \$deselect_all_serials); $checkbox_deselectAll_serials->deselect(); my $save_button_serials = $pane->Button (-text => 'Save & Exit', -command => \&save_exit_serials,-foreground =>'red',-background =>'black'); # close window if [x] is pressed and uncheck $defineSerialsWindow->protocol( 'WM_DELETE_WINDOW', sub { $defineSerialsWindow->withdraw(); return; } ); ############################Einlesen der Seriennummern aus Artis_31-01-2012.xls####################### my $label_listingSerials; my $line = undef; my @defineserials = ""; my @checkboxarray = undef; my $checkbox_listingSerials; my @label_listingSerials = undef; my @checkbox_listingSerials = undef; # Open File and Worksheet my $Book = $Excel->Workbooks->Open ($current_folder."\\data\\".'Artis_31-01-2012.xls'); # open Excel file my $Sheet = $Book->Worksheets(1); my $array = $Sheet->Range("B2:B8012")->{'Value'}; foreach my $ref_array (@$array) { foreach my $scalar (@$ref_array) { push(@defineserials, $scalar); } } $Book->Close; # close excelsheet # sort entries lexically @defineserials = sort @defineserials; # define no of rows and columns, number of rows is hard-coded (50), could be smaller ?? my $amount_rows = 500; my $amount_col = ($#defineserials/$amount_rows)+1; my @var_serial; #checkbutton checked or unchecked ? : checked => $var = 1; unchecked => $var = 0 ###### pack widgets (labels and checkboxes in right columns and rows) my $cnt_entries = 1; LOOPEntries: for my $col_ctr(0..$amount_col) { for my $row_ctr(2..$amount_rows) { # put values to variable and take the counter for the packing of the widgets (checkbox, label) $label_listingSerials[$cnt_entries] = $pane->Label(-text=> $defineserials[$cnt_entries]); $checkbox_listingSerials[$cnt_entries] = $pane->Checkbutton (-command =>[\&used_serials, $defineserials[$cnt_entries], $cnt_entries], -variable => \$var_serial[$cnt_entries], -onvalue => 1, -offvalue =>0); #pack the widgets on the pane $label_listingSerials[$cnt_entries]->grid(-row=>$row_ctr, -column=>$col_ctr*2+1, -sticky=>'w'); $checkbox_listingSerials[$cnt_entries]->grid(-row=>$row_ctr, -column=>$col_ctr*2); push(@checkboxarray, $checkbox_listingSerials[$cnt_entries] ); $cnt_entries++; if ($cnt_entries == $#defineserials+1) #modified by FDu - 10.09.2012 => last index missing; old: $#defineserials; new: $#defineserials+1 { last LOOPEntries; } } } $checkbox_selectAll_serials->grid(-row=>0, -column=>0); $label_selectAll_serials->grid(-row=>0, -column=>1, -sticky=>'w'); $checkbox_deselectAll_serials->grid(-row=>1, -column=>0); $label_deselectAll_serials->grid(-row=>1, -column=>1, -sticky=>'w'); $save_button_serials->grid(-row => 0, -column => 2, -padx => 4); $pane->pack(-fill => 'both', -expand => 1);