use strict; use warnings; use 5.010; use Tk; #use Win32::Console; #Win32::Console::Free(); system("cls"); # declarations my $netspdx=1; my $netspdy=0; my $netuse=0.05; my $fsizex=3; my $fsizey=0; my $mw; my $breed=400; my $hoog=200; my $cent=$breed/2; # needs -anchor=>'center' my $tekst; my $button; my $but1; my $but2; my $but3; my $but4; my $but5; my $but6; my $entry1; my $entry2; my $entry3; my $col0=40; # need -anchor=>'w' my $col1=$cent-35; # need -anchor=>'w' my $col2=$cent+30; # need -anchor=>'w' my $col3=$breed-40; # need -anchor=>'w' my $row0=20; my $row1=40; my $row2=60; my $row3=80; my $row4=90; my $row5=110; initi(); $tekst=$mw -> Label(-text=>"Fill in the fields and check the right boxes") -> place(-x=>$cent, -y=>$row0, -anchor=>'center'); $tekst=$mw -> Label(-text=>"Network speed") -> place(-x=>$col0, -y=>$row1, -anchor=>'w'); $entry1=$mw -> Entry(-justify=>'right',-textvariable=> \$netspdx, -width=>5) -> place(-x=>$cent, -y=>$row1, -anchor=>'center'); $but1=$mw -> Radiobutton(-text => 'Gb', -variable=>\$netspdy, -value=>1000000000) -> place(-x=>$col2, -y=>$row1, -anchor=>'w'); $but1->select(); $but2=$mw -> Radiobutton(-text => 'Mb', -variable=>\$netspdy, -value=>1000000) -> place(-x=>$col2+50, -y=>$row1, -anchor=>'w'); $but3=$mw -> Radiobutton(-text => 'Kb', -variable=>\$netspdy, -value=>1000) -> place(-x=>$col2+100, -y=>$row1, -anchor=>'w'); $tekst=$mw -> Label(-text=>"Avg network use in %") -> place(-x=>$col0, -y=>$row2, -anchor=>'w'); $entry2=$mw -> Entry(-justify=>'right',-textvariable=> \$netuse,-width=>5) -> place(-x=>$cent, -y=>$row2, -anchor=>'center'); $tekst=$mw -> Label(-text=>"File size") -> place(-x=>$col0, -y=>$row3, -anchor=>'w'); $entry3=$mw -> Entry(-justify=>'right',-textvariable=> \$fsizex,-width=>5) -> place(-x=>$cent, -y=>$row3, -anchor=>'center'); $but4=$mw -> Radiobutton(-text => 'GB', -variable=>\$fsizey, -value=>1000000000) -> place(-x=>$col2, -y=>$row3, -anchor=>'w'); $but4->select(); $but5=$mw -> Radiobutton(-text => 'MB', -variable=>\$fsizey, -value=>1000000) -> place(-x=>$col2+50, -y=>$row3, -anchor=>'w'); $but6=$mw -> Radiobutton(-text => 'KB', -variable=>\$fsizey, -value=>1000) -> place(-x=>$col2+100, -y=>$row3, -anchor=>'w'); $tekst= $mw -> Label(-text=>"Estimated time") -> place(-x=>$col0, -y=>$row5, -anchor=>'w'); $tekst= $mw -> Label(-text=>"minutes") -> place(-x=>$col2, -y=>$row5, -anchor=>'w'); endi(); # subroutines # init info sub initi{ $mw = new MainWindow(-height=>$hoog,-width=>$breed,-title=>'Downloadtime estimator'); $mw -> geometry("+100+100"); } # end info sub endi { $button = $mw -> Button(-text => "Okay", -command => sub { $tekst= $mw -> Label(-text=>" ") -> place(-x=>$cent, -y=>$row5, -anchor=>'center'); # not very elegant, any ideas ? $tekst= $mw -> Label(-text=> int( (($fsizex*$fsizey) / ((($netspdx*$netspdy)/100) *$netuse)) /60 ) )-> place(-x=>$cent, -y=>$row5, -anchor=>'center'); }) -> place(-x=>$col0, -y=>$hoog-50, -anchor=>'w'); $button = $mw -> Button(-text => " Exit ", -command => sub { exit }) -> place(-x=>$col3, -y=>$hoog-50, -anchor=>'e'); MainLoop; }