#!/usr/local/bin/perl use Tk; #Global Variables my $bins = 10; my $process = "180nm"; # Main Window my $mw = new MainWindow; #GUI Building Area: User specifies file location my $frm_name = $mw -> Frame(); my $lab = $frm_name -> Label(-text=>"File Name:"); my $ent = $frm_name -> Entry(); #Number of bins my $scl = $mw -> Scale(-label=>"Number of bins :", -orient=>'h', -digit=>1, -from=>10, -to=>100, -variable=>\$bins, -tickinterval=>25); #Select the process my $frm_process = $mw -> Frame(); my $lbl_process = $frm_process -> Label(-text=>"Process "); my $rdb_40 = $frm_process -> Radiobutton(-text=>"40nm:GF", -value=>"40nm", -variable=>\$process); my $rdb_65 = $frm_process -> Radiobutton(-text=>"65nm:GF", -value=>"65nm",-variable=>\$process); my $rdb_140 = $frm_process -> Radiobutton(-text=>"140nm:NXP", -value=>"140nm", -variable=>\$process); my $rdb_180 = $frm_process -> Radiobutton(-text=>"180nm:GF", -value=>"180nm",-variable=>\$process); my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button); #Text Area my $textarea = $mw -> Frame(); my $txt = $textarea -> Text(-width=>40, -height=>10); my $srl_y = $textarea -> Scrollbar(-orient=>'v',-command=>[yview => $txt]); my $srl_x = $textarea -> Scrollbar(-orient=>'h',-command=>[xview => $txt]); $txt -> configure(-yscrollcommand=>['set', $srl_y], -xscrollcommand=>['set',$srl_x]); #Geometry Management $lab -> grid(-row=>1,-column=>1); $ent -> grid(-row=>1,-column=>2); $scl -> grid(-row=>2,-column=>1, -ipadx =>100); $frm_name -> grid(-row=>1,-column=>1,-columnspan=>2); $lbl_process -> grid(-row=>1,-column=>1); $rdb_40 -> grid(-row=>1,-column=>2); $rdb_65 -> grid(-row=>1,-column=>3); $rdb_140 -> grid(-row=>1,-column=>4); $rdb_180 -> grid(-row=>1,-column=>5); $frm_process -> grid(-row=>3,-column=>1,-columnspan=>2); $but -> grid(-row=>4,-column=>1,-columnspan=>2); $txt -> grid(-row=>1,-column=>1); $srl_y -> grid(-row=>1,-column=>2,-sticky=>"ns"); $srl_x -> grid(-row=>2,-column=>1,-sticky=>"ew"); $textarea -> grid(-row=>5,-column=>1,-columnspan=>2); MainLoop; ## Functions #This function will be executed when the button is pushed sub push_button { my $name = $ent -> get(); open(my $in0, '>', 'input.txt') or die "Cannot open input.txt file: $!. You might need to run the script from a location where you have write access"; print $in0 $name, "\n"; print $in0 $process, "\n"; print $in0 $bins, "\n"; close $in0; $txt -> insert('end',"Process is $process. File location is $name and selected bins is $bins.\n"); }