I used the sub program way because I have the sub window do some functions before closing so I cannot call close right in the declerative region for the button. However I have a problem getting the window to close multiple times. It works fine the first time but when I call the window again it opens and then when I execute the function it errors while trying to close the second time.
sub go_to { my $sw = $mw->Toplevel(-title=>"Go To Line"); my $frame = $sw->Frame->pack(-side => 'top', -fill => 'x'); $frame->Label(-text => "Enter Line Number:")->pack(-side => 'left', + -anchor => 'w'); $frame->Entry(-textvariable => \$line_number)-> pack(-side => 'left', -anchor => 'w', -fill => 'x', -expand => 1 +); $frame->Button(-text => "GO", -background => 'navy blue', -foregrou +nd => 'white', -command =>\&scroll_line)-> pack(-side => 'right'); sub scroll_line { $line_number = $line_number - 1; my $calc = $line_number/$line_count; $t->yviewMoveto($calc); $line_number = $line_number + 1; $sw->destroy(); } }
As you might be able to tell the sub window is a "go to" line function in a text editor script I am writing and needs to be opened and closed multiple time during one session. How can I change it to do this more than once successfully. The error is:
Tk::Error: Usage $widget->destroy(...) at C:\Documents and Settings\My_Name\My Documents\scripts\perl_edit.pl line 343. \&main::scroll_line Tk callback for .toplevel.frame.button Tk::__ANON__ at C:/Perl/site/lib/Tk.pm line 228 Tk::Button::butUp at C:/Perl/site/lib/Tk/Button.pm line 111 (command bound to event) destroy (1): 0 0x1a6dfe4 RV f=00080503 {}(1)(1) SV = RV(0x2104260) at 0x1a6dfe4 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x2145d78

In reply to Re: Re: clsoing sub window upon execution? by Elijah
in thread clsoing sub window upon execution? by Elijah

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.