I am trying to create a Perl program (Perl Tk GUI) that runs different scripts based on what users choose out of a menu at the top. The scripts output text progress and feedback based on records that the script processed into a Scrolled widget/element. I want to be able to forget/destroy/delete the widget when I move to a new option in the menu so I can create a fresh one to output text from the next script the user will run.

my $mainFrame = $mw->Frame()->pack(-side=>'top'); my $tx = $mainFrame->Scrolled(qw/Text -font normal -width 73 -height 15 -wrap word -scrollbars e/); $tx->pack; tie *STDOUT, 'Tk::Text', $tx; #script is called, runs, outputs to Scrolled above, user chooses new o +ption and sub clear() is called: sub clear{ $mainFrame ->destroy(); $tx ->pack('forget'); }

I want the $tx widget to disappear/clear off the screen

I have tried multiple things like forget, destroy, delete and anything else I could find on this site and around the interwebs. Some of them don't throw errors at all, but when I go to run a different script, the Scrolled widget/element will not clear from the screen so the new one shows up below the old one. I am relatively new to Perl GUI programming (this is my first GUI with Perl and I am trying to learn it as I go) so go easy on me

</code>

In reply to Perl Tk Forgetting a Widget by amdme127

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.