1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| #!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = MainWindow->new();
$mw->title("BB!");
$mw->geometry("300x100");
my $b_menu = $mw->Frame( -relief => 'groove', -borderwidth => 2 );
my $menu_app = $b_menu->Menubutton(
-text => "File",
-tearoff => 0,
-relief => 'ridge',
-menuitems => [
[ 'command' => "Create new TLSE", -command => \&create_tlse ],
[ 'command' => "Delete TLSE", -command => \&delete_tlse ],
[ 'command' => "Exit", -command => sub { exit; } ]
]
);
$menu_app->pack( -side => 'left' );
$b_menu->pack( -side => 'top', -anchor => 'n', -fill => 'x' );
#Frame containing all TLSE
my $all_tlse = $mw->Frame( -relief => 'raised', -borderwidth => 2 )->pack();
my $end = $mw->Label(
-relief => 'groove',
-text => "2010",
-font => '{Garamond} 10'
)->pack( -side => 'bottom', -fill => 'both' );
MainLoop;
#---------------------Subfonction------------------------------
sub create_tlse {
my $tlse_creation = $mw->Toplevel();
my $tlse_creation_title = $tlse_creation->Label( -text => "Create a new TLSE" )->pack();
my $ent_name = $tlse_creation->Entry()->pack();
my $valid_button = $tlse_creation->Button(
-text => "Create",
-command => [ \&tlse, $ent_name ]
)->pack( -side => 'left' );
my $but_close = $tlse_creation->Button(
-text => "Close",
-command => sub { destroy $tlse_creation; }
)->pack();
return;
}
sub tlse {
my ($ent_name) = @_;
#Frame TLSE
my $tlse_name = $all_tlse->Frame(
-relief => 'groove',
-borderwidth => 2
)->pack( -side => 'left' );
my $name = $ent_name->get();
#create the entry in the bb file
my $bb_base = "TLSE-data.bb";
open( FILE, '>>', $bb_base ) or die("problem to open the bb file.");
print FILE "\n";
print FILE $name;
#By default, at the TLSE creation, the workload is set to 0
print FILE ";0;";
close FILE;
my $lb_name = $tlse_name->Label( -text => "$name" )->pack( -side => 'top' );
#By default, at the TLSE creation, the workload is set to 0
my $valeur_workload = 0;
my $lb_workload = $tlse_name->Label( -textvariable => \$valeur_workload )->pack();
my $minus_button = $tlse_name->Button(
-text => "-",
-command => [ \&push_minus, \$valeur_workload ]
)->pack( -side => 'left' );
my $plus_button = $tlse_name->Button(
-text => "+",
-command => [ \&push_plus, \$valeur_workload ]
)->pack( -side => 'right' );
return;
}
sub push_minus {
my ($ref_valeur_workload) = @_;
# deférencement et incrementation
${$ref_valeur_workload}--;
return;
}
sub push_plus {
my ($ref_valeur_workload) = @_;
# deférencement et incrementation
${$ref_valeur_workload}++;
return;
} |
Partager