samedi 18 avril 2020

PERL tk module handling

I am using tk module to build a checklist for user to choose. I am totally beginner to this module. Currently the checklist created is all in the same series column, since it will be a long list, any idea how could I separate few of the options to another column? Also, any idea how to align those text to the left while checkbox to the right? To display it cleanly and neatly.

#!/usr/bin/perl
use Tk;


$main = MainWindow->new();
$label = $main->Label(-text => "Presence Check");

$label->pack();
$frame = $main->Frame(-relief=>"groove", -borderwidth=>2);
#$frame = $main->Frame(-relief=>"groove", -borderwidth=>2)->pack(-side => 'top', -expand => 1, -fill =>'both');
#$frame = $main->Frame->pack(-side => 'left', -fill => 'x');



$check1 = $frame->Checkbutton(-text=>"Document A (docx, pdf)",
                          -variable=>\$a,
                  -onvalue=>"APRESENT",
                  -offvalue=>"AABSENT");

#$check1->pack(-side=>"top");
$check2 = $frame->Checkbutton(-text=>"Document B (xlsx)",
                          -variable=>\$b,
                  -onvalue=>"BPRESENT",
                  -offvalue=>"BABSENT");

$check2->pack(-side=>"top");

$check3 = $frame->Checkbutton(-text=>"C specification",
                          -variable=>\$c,
                  -onvalue=>"CPRESENT",
                  -offvalue=>"CABSENT");

$check3->pack(-side=>"top");

$check4 = $frame->Checkbutton(-text=>"A-Specification",
                          -variable=>\$aspec,
                  -onvalue=>"ASPECPRESENT",
                  -offvalue=>"ASPECSABSENT");

$check4->pack(-side=>"top");

$check5 = $frame->Checkbutton(-text=>"Important Report",
                          -variable=>\$report,
                  -onvalue=>"REPORTPRESENT",
                  -offvalue=>"REPORTSABSENT");

$check5->pack(-side=>"top");

$check6 = $frame->Checkbutton(-text=>"Handbook",
                          -variable=>\$handbook,
                  -onvalue=>"HANDBOOKPRESENT",
                  -offvalue=>"HANDBOOKABSENT");

$check6->pack(-side=>"top");

$check7 = $frame->Checkbutton(-text=>"Data Spreadsheet",
                          -variable=>\$dataxls,
                  -onvalue=>"DATAPRESENT",
                  -offvalue=>"DATAABSENT");

$check7->pack(-side=>"top");

$check8 = $frame->Checkbutton(-text=>"D file",
                          -variable=>\$dfile,
                  -onvalue=>"DFILEPRESENT",
                  -offvalue=>"DFILEABSENT");

$check8->pack(-side=>"top");


$check10 = $frame->Checkbutton(-text=>"xx doc",
                          -variable=>\$xxdoc,
                  -onvalue=>"XXDOCPRESENT",
                  -offvalue=>"XXDOCABSENT");

$check10->pack(-side=>"top");

$check18 = $frame->Checkbutton(-text=>"yy Doc",
                          -variable=>\$yydoc,
                  -onvalue=>"YYDOCPRESENT",
                  -offvalue=>"YYDOCABSENT");

$check18->pack(-side=>"top");
$frame->pack();

$button = $main->Button(-text => "Exit",
                        -command => \&exit_button);
$button->pack();
MainLoop();

sub exit_button {
print "$a $b $c $aspec $report $handbook $dataxls $dfile $xxdoc $yydoc \n";
#print "$rv\n";
exit,
}



Aucun commentaire:

Enregistrer un commentaire