I've created a static text control inside the status bar control so that I can display colored text there like so:
my $status = Wx::StatusBar->new($parent,wxSB_RAISED); $status->SetForegroundColour(wxRED); my $warning = Wx::StaticText->new ($status, wxID_ANY,"Input Error!");
But how do I destroy the text control so that I can display status text in the same position without getting blocked? I've tried:
$warning->Destroy(); $status->SetStatusText("OK",0);
But it does not seem to have any effect. Any pointers? Thanks like always.

UPDATE

Thanks Anonymous Monks :)

I had tried the Hide and Show methods before posting the question but it didn't seem to work. But now after playing around with the demo code you kindly offered here, I think I am able to get the hide and show to work as expected. Thanks :) But I'm still missing something obvious. The following code shows my problem: why I can't destroy the control?

use strict; use warnings; use Wx ':everything'; my $window = Wx::Frame->new(undef, -1, "Colored Statusbar Text"); my $panel = Wx::Panel->new($window); my $button = Wx::Button->new( $panel, -1, "Toggle", ); Wx::Event::EVT_BUTTON( $button, -1, \&button_click, ); my $status = $window->CreateStatusBar(2, wxSB_RAISED); $window->Show; my $hit =1; Wx::SimpleApp->new->MainLoop; sub button_click { $hit++; my $warning = Wx::StaticText->new($status, -1, "Input Error",,[3,8 +]); $warning->SetForegroundColour(wxRED); if ($hit % 2) { $status->SetStatusText("", 0); $warning->Show; } else { $warning->Destroy; $status->SetStatusText("OK", 0); } }

UPDATE2

The hide and show methods seem to work:
use strict; use warnings; use Wx ':everything'; my $window = Wx::Frame->new(undef, -1, "Colored Statusbar Text"); my $panel = Wx::Panel->new($window); my $button = Wx::Button->new( $panel, -1, "Toggle", ); Wx::Event::EVT_BUTTON( $button, -1, \&button_click, ); my $status = $window->CreateStatusBar(2, wxSB_RAISED); my $warning = Wx::StaticText->new($status, -1, "Input Error",,[3,8]); $warning->SetForegroundColour(wxRED); $window->Show; my $hit =1; Wx::SimpleApp->new->MainLoop; sub button_click { $hit++; if ($hit % 2) { $status->SetStatusText("", 0); $warning->Show; } else { $warning->Hide; $status->SetStatusText("OK", 0); } }

In reply to How do I destroy a control after its creation in wxPerl? by ZJ.Mike.2009

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.