http://qs1969.pair.com?node_id=904074

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

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); } }