Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found