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

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

Replies are listed 'Best First'.
Re^3: clsoing sub window upon execution?
by sumanth123 (Initiate) on Mar 19, 2015 at 09:02 UTC

    Whats the solution for this ??? Could you share, if you have figured it out... i know its a long time since this post! But i am working on something similar and have the same issue!