Hi everyone, I'm developing a small application that reads multiple reports and displays some results. I'm using spreadsheet::parseExcel and have developed GUI using perl/Tk.
Now, i'm facing two issues mainly:

1. I'm not very well versed with the bind option. I'm finding it a little difficult to attach it the callback of a subroutine. Now the problem is , everytime i close the window and try opening it back again, it gives me this error

2. The script i'm using parses the values in an excel file by the row/column numbers of the multiple excel files. I'm able to run this script on a test file but when i try to run it for a different file, it just doesnt work. In addition it gives me this error.
error:not a Tk object Tk::die_with_trace at G:/Dwimperl/Perl/site/lib/Tk.pm line 251 Tk::__ANON__ at final_code.pl line 141 main::push_button1 at G:/Dwimperl/Perl/site/lib/Tk.pm line 251 (eval) at G:/Dwimperl/Perl/site/lib/Tk.pm line 251 Tk::__ANON__ at G:/Dwimperl/Perl/site/lib/Tk/Button.pm line 175 Tk::Button::butUp at G:/Dwimperl/Perl/site/lib/Tk.pm line 424 (eval) at G:/Dwimperl/Perl/site/lib/Tk.pm line 424 Tk::MainLoop at final_code.pl line 87 Tk callback for .button Tk::__ANON__ at G:/Dwimperl/Perl/site/lib/Tk.pm line 251 Tk::Button::butUp at G:/Dwimperl/Perl/site/lib/Tk.pm line 175 <Button-Release1>

This is becoming really frustrating now. Please help

Attached is code below:
use Tk; # Main Window my $mw = new MainWindow; $mw->Frame(-background => 'red')->pack(-ipadx =>50, -side => "left", - +fill => "y"); #Making a text area my $txt = $mw -> Scrolled('Text',-width => 150, height => 40, -scrollb +ars=>'e', -font => "fixed 8 bold" ) -> pack (); $txt->insert('end', ""); #Declare that there is a menu my $mbar = $mw -> Menu(); $mw -> configure(-menu => $mbar); #The Main Buttons my $file = $mbar -> cascade(-label=>"File", -underline=>0, -tearoff => + 0); my $tool= $mbar -> cascade(-label =>"Tools", -underline=>0, -tearoff = +> 0); my $parser = $mbar -> cascade(-label =>"RL Parser", -underline=>0, -te +aroff => 0); my $help = $mbar -> cascade(-label =>"Help", -underline=>0, -tearoff = +> 0); ## File Menu ## $file -> command(-label => "Home", -underline=>0, -command=> \&home ); $file -> command(-label => "Check KPI definitions", -underline=>0, -command=> \&define ); $file -> checkbutton(-label =>"Check for faults", -underline => 0, -command => \&faults); $file -> separator(); $file -> command(-label =>"Exit", -underline => 1, -command => sub { exit } ); ## Tools Menu ## $tool -> command(-label => "Network planning", -underline=>0, -command=> \&nwplan ); $tool -> command(-label => " ", -underline=>0, -command=> \&optimize ); $tool -> separator(); $tool -> command(-label =>"Network Planning Rules", -underline =>1, -command => sub { $txt -> delete('1.0', 'end'); <br/> sub define { my $mw = new MainWindow; # Main Window my $frm_name = $mw -> Frame(); my $lab = $frm_name -> Label(-text=>"Enter KPI:"); my $ent = $frm_name -> Entry(); my $but = $mw -> Button(-text=>"Check", -command =>\&push_button1); my $textarea = $mw -> Frame(); #Creating Another Frame my $txt = $textarea -> Text(-width=>130, -height=>30, -font=> "fixed 1 +0 bold"); my $srl_y = $textarea -> Scrollbar(-orient=>'v',-command=>[yview => $t +xt]); my $srl_x = $textarea -> Scrollbar(-orient=>'h',-command=>[xview => $t +xt]); $txt -> configure(-yscrollcommand=>['set', $srl_y], -xscrollcommand=>['set',$srl_x]); $lab -> grid(-row=>1,-column=>1); $ent -> grid(-row=>1,-column=>2); $frm_name -> grid(-row=>1,-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); $txt -> insert('end'," *some text* ");} else {$txt -> delete('1.0', 'end'); $txt -> insert('end'," Wrong Keyword. Please Try Again"); } } }

In reply to Error Not a tk object / Problems with multiple files by reaper9187

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.