use Tk 800.000; # These are all the modules that we are using in this script. use Tk::Frame; use Tk::TextUndo; use Tk::Text; use Tk::Scrollbar; use Tk::Menu; use Tk::Menubutton; use Tk::Adjuster; use Tk::DialogBox; use Tk::NoteBook; use Tk::LabEntry; use Data::Dumper; use Scalar::Util qw(reftype); use strict; # Always! $^W++; # Turn on warnings my $DEBUG = 1; # turn off (0) if you don't want to see internals my $mainwindow; my $f; # dialog window my $chipname = "chip"; my $user = "user"; my $config = { SETUPCORNER => ["ss1", "ss2", "ss3", "ss4"], HOLDCORNER => ["ff1", "ff2", "ff3", "ff4", "ff5", "ff6", "ff7", "ff8"], IOHOLD => '0', CHIPNAME => "${chipname}", PTCORNERSUMM => '0', WNS_GREEN => '-0.005', WNS_YELLOW_START => '-0.006', WNS_YELLOW_END => '-0.149', WNS_RED => '-0.150', }; MAIN: { debug("+MAIN"); $mainwindow = MainWindow->new(); $mainwindow->title("Summary Extractor"); $mainwindow->configure(-background => 'cyan'); my $menubar = $mainwindow->Frame(-relief => 'groove', -borderwidth => 3)->pack(-side => 'top', -fill => 'x'); my $ptcorns = $mainwindow->Frame(-borderwidth => 2, -border => 2, -relief => 'groove')->pack( -fill => 'x'); my $dir_flename = $mainwindow->Frame(-borderwidth => 2, -border => 2, -relief => 'groove')->pack( -fill => 'x'); my $allbuttons = $mainwindow->Frame()->pack(-fill => 'x'); my $filemenu = $menubar->Menubutton(-text => 'File'); $filemenu->command( -label => 'Open Config', -command => \&loadConfig ); $filemenu->command( -label => 'Save Config', -command => \&saveConfig ); $filemenu->separator(); $filemenu->command( -label => 'Configuration', -command => \&doConfig ); $filemenu->separator(); $filemenu->command( -label => 'Exit', -command => sub {exit;} ); $filemenu->pack(-side => 'left'); my $help_mb = $menubar->Menubutton(-text => 'Help',-borderwidth => 3)->pack(-side => 'right'); $help_mb->command(-label => 'About', -command => \&about_program); $help_mb->command(-label => 'Help', -command => \&help); $help_mb->separator(); my $buttons_0 = $allbuttons->Frame()->pack(-fill => 'x'); my $buttons_1 = $allbuttons->Frame()->pack(-fill => 'x'); $buttons_0->Button(-text => 'Load Config', -background => 'red', -command => \&loadConfig )->pack( -side => 'left', -pady => 2, -padx =>2, -fill => "both", -expand => 1); $buttons_0->Button(-text => 'Save Config', -background => 'red', -command => \&saveConfig )->pack( -side => 'left', -pady => 2, -padx =>2, -fill => "both", -expand => 1); $buttons_0->Button(-text => 'Configuration', -background => 'red', -command => \&doConfig )->pack( -side => 'left', -pady => 2, -padx =>2, -fill => "both", -expand => 1); $buttons_0->Button(-text => 'Exit', -background => 'red', -command => sub{exit} )->pack( -side => 'left', -pady => 2, -padx =>2, -fill => "both", -expand => 1); my $chip_frm = $ptcorns->Frame(-borderwidth => 2, -border => 2, -relief => 'groove')->pack(-side => 'top', -pady => 9, -padx => 9, -fill => 'x'); my $ptcorners = $ptcorns->Frame(-borderwidth => 2, -border => 2, -relief => 'groove')->pack(-side => 'left', -pady => 9, -padx => 9, -fill => 'x'); my $chip_frme = $chip_frm->Frame(-relief => 'groove', )->pack(-side => 'top'); my $chkbut_frame = $ptcorners->Frame(-relief => 'groove',)->pack(-side => 'top'); my $lab_frame = $ptcorners->Frame(-relief => 'groove', )->pack(-side => 'left'); my $chip_lab = $chip_frme->LabEntry(-label => 'CHIP NAME:', -background => 'white', -labelPack => [-side => 'left', -anchor => 'w'], -textvariable => \$config->{CHIPNAME}, -width => '40')->pack(-pady => 2); my $setupent = my $setuplabent = my $holdlabent = my $setuplab = my $holdent = my $holdlab = ""; my $chk = $chkbut_frame->Checkbutton(-text => "Pt Timing Summ ?:", -variable => \$config->{PTCORNERSUMM}, -relief => 'groove', -borderwidth => 2, -command => sub { if ($config->{PTCORNERSUMM}) { $setuplabent->configure( -state => 'normal'); $holdlabent->configure( -state => 'normal'); } else { $setuplabent->configure( -state => 'readonly'); $holdlabent->configure( -state => 'readonly'); }})->pack(-side => 'left',-anchor => 'w', -expand => 1, -pady => 2, -fill => 'both'); $setuplabent = $lab_frame->LabEntry(-label => 'Setup Corners :', -background => 'white', -labelPack => [-side => 'left', -anchor => 'w'], -textvariable => \$config->{SETUPCORNER}, -width => '40')->pack(-pady => 2); $holdlabent = $lab_frame->LabEntry(-label => 'Hold Corners :', -background => 'white', -labelPack => [-side => 'left', -anchor => 'w'], -textvariable => \$config->{HOLDCORNER}, -width => '40')->pack(-pady => 2); $setuplabent->configure( -state => $config->{PTCORNERSUMM} ? 'normal' : 'readonly'); $holdlabent->configure( -state => $config->{PTCORNERSUMM} ? 'normal' : 'readonly'); while (1) { eval MainLoop(); # Start the event processing } # Will never get here debug ("-MAIN"); } ####################### #Sub routines sub debug { my @msg = shift; print @msg, "\n" if $DEBUG; } sub doConfig { debug("+doConfig"); my $localconfig; # Copy all the configuration items to a local array foreach (keys %$config) { $localconfig->{$_} = $config->{$_}; #debug ($_); } if (not defined $f) { $f = $mainwindow->DialogBox(-title => "Color Configuration", -buttons => ["Load", "Save", "OK", "Cancel"]); my $n = $f->add('NoteBook', -ipadx => 6, -ipady => 6); my $timing = $n->add("timing", -label => "TIMING", -underline => 0); my $wns_frm = $timing->Frame(-borderwidth => 2, -border => 2, -relief => 'groove', )->pack(-side => 'top', -fill => 'x'); my $tns_frm = $timing->Frame(-borderwidth => 2, -border => 2, -relief => 'groove', )->pack(-side => 'top', -fill => 'x'); my $fep_frm = $timing->Frame(-borderwidth => 2, -border => 2, -relief => 'groove', )->pack(-side => 'top', -fill => 'x'); my $wns_header = $wns_frm->Frame(-relief => 'groove', )->pack(-side => 'top', -fill => 'x'); my $wns_lbl_frm = $wns_frm->Frame(-relief => 'groove', )->pack(-side => 'left'); my $wns_ent_frm = $wns_frm->Frame(-relief => 'groove', )->pack(-side => 'left'); my $wns_lbl_frm1 = $wns_frm->Frame(-relief => 'groove', )->pack(-side => 'left'); my $wns_ent_frm1 = $wns_frm->Frame(-relief => 'groove', )->pack(-side => 'left'); my $wns_name = $wns_header->Label(-text => 'TIMING WNS')->pack(-pady => 2); my $wns_lbl1 = $wns_lbl_frm->Label(-background => 'green', -text => 'Lime (>=)')->pack(-pady => 2, -anchor => 'w'); # my $wns_ent1 = $wns_ent_frm->Entry(-textvariable => \$start_wns, -width => '8')->pack(-pady => 2); my $wns_lbl2 = $wns_lbl_frm1->Label(-text => ':')->pack(-pady => 2); my $wns_ent2 = $wns_ent_frm1->Entry(-textvariable => \$localconfig->{WNS_GREEN}, -width => '8')->pack(-pady => 2); my $wns_lbl3 = $wns_lbl_frm->Label(-background => 'yellow', -text => 'Yellow (between)')->pack(-pady => 2, -anchor => 'w'); my $wns_ent3 = $wns_ent_frm->Entry(-textvariable => \$localconfig->{WNS_YELLOW_START}, -width => '8')->pack(-pady => 2); my $wns_lbl4 = $wns_lbl_frm1->Label(-text => ':')->pack(-pady => 2); my $wns_ent4 = $wns_ent_frm1->Entry(-textvariable => \$localconfig->{WNS_YELLOW_END}, -width => '8')->pack(-pady => 2); my $wns_lbl5 = $wns_lbl_frm->Label(-background => 'red', -text => 'Red (<=)')->pack(-pady => 2, -anchor => 'w'); # my $wns_ent5 = $wns_ent_frm->Entry(-textvariable => \$start_wns, -width => '8')->pack(-pady => 2); my $wns_lbl6 = $wns_lbl_frm1->Label(-text => ':')->pack(-pady => 2); my $wns_ent6 = $wns_ent_frm1->Entry(-textvariable => \$localconfig->{WNS_RED}, -width => '8')->pack(-pady => 2); $n->pack(-expand => "yes", -fill => "both", -padx => 5, -pady => 5, -side => "top"); } my $result = $f->Show; # Execute the dialog box if ($result =~ /OK/) { # Copy all the configuration items back foreach (keys %$config) { $config->{$_} = $localconfig->{$_}; } debug(Dumper $config); } debug("-doConfig"); } sub loadConfig {} sub saveConfig {} sub defaultConfig {}