Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

wxPerl window colors

by sdetweil (Sexton)
on Jan 19, 2013 at 15:02 UTC ( #1014212=perlquestion: print w/ replies, xml ) Need Help??
sdetweil has asked for the wisdom of the Perl Monks concerning the following question:

not technically a perl question, but app written in Perl, and the widest skill base is clearly here.

so, my users want to change the colors of one of the windows in our application..

it is a wxPerl wxTextCtrl

the code does a wxSetForegroundColour() and wxSetBackgroundColour(), and then does a window->Update

the background changes. the foreground does not.. except, when we write more info to the window, it comes out with the new foreground color.

# in RGB colors $detailsInfo->SetBackgroundColour(Wx::Colour->new($tokens[1], $tokens[ +2], $tokens[3])); $detailsInfo->SetForegroundColour(Wx::Colour->new($tokens[1], $tokens[ +2], $tokens[3])); $detailsInfo->Refresh();
we tried $detailsInfo->Update();

of course this only fails on *ix, on Windows it behaves as expected.

so there must be some rules about a multiline text control in gtk that I don't understand.

Comment on wxPerl window colors
Download Code
Re: wxPerl window colors
by stefbv (Chaplain) on Jan 19, 2013 at 17:54 UTC

    It works fine for me on GNU/Linux:

    package Frame; use strict; use warnings; use Wx qw[:everything]; use base qw(Wx::Frame); sub new { my $self = shift; $self = $self->SUPER::new( undef, -1, 'Test app', [-1, -1], [-1, -1], wxDEFAULT_FRAME_STYLE, ); #- Grid Sizer my $sizer = Wx::GridSizer->new(2, 1); my $text = Wx::TextCtrl->new( $self, -1, q{Hello}, [ -1, -1 ], [ -1, 40 ], wxTE_MULTILINE, ); my $button = Wx::Button->new( $self, -1, '&Color',[ 70, 30 ] ); my $hbox = Wx::BoxSizer->new(wxHORIZONTAL); Wx::Event::EVT_BUTTON( $self, $button, sub { $text->SetForegroundColour( Wx::Colour->new(255,0,0) ); $text->SetBackgroundColour( Wx::Colour->new('yellow') ); } ); $sizer->Add( $text, 0, wxALIGN_CENTRE | wxGROW | wxALL, 2, ); $sizer->Add( $button, 0, wxALIGN_CENTRE | wxGROW | wxALL, 2, ); $self->SetSizer( $sizer ); $sizer->Fit($self); return $self; } 1; package App; use strict; use warnings; use base 'Wx::App'; sub OnInit { my $frame = Frame->new(); $frame->Show( 1 ); } package main; use strict; use warnings; my $app = App->new(); $app->MainLoop;

    Regards, Stefan

      thanks.. that is good to know.. more research.. the test system is fedora 12 32bit. some of the target systems are older unfortunately.
Re: wxPerl window colors
by jmlynesjr (Pilgrim) on Jan 20, 2013 at 02:56 UTC

    From:

    wxWidgets 2.8.10: A portable C++ and Python GUI toolkit

    Julian Smart, Robert Roebling, Vadim Zeitlin, Robin Dunn, et al

    SetBackgroundColour

    ----------------------------------

    Remarks

    The background colour is usually painted by the default wxEraseEvent (p. 571) event handler function under Windows and automatically under GTK. Note that setting the background colour does not cause an immediate refresh, so you may wish to call wxWindow::ClearBackground (p. 1802) or wxWindow::Refresh (p. 1831) after calling this function.

    Using this function will disable attempts to use themes for this window, if the system supports them. Use with care since usually the themes represent the appearance chosen by the user to be used for all applications on the system.

    SetForegroundColour

    ----------------------------------

    Remarks

    The interpretation of foreground colour is open to interpretation according to the window class; it may be the text colour or other colour, or it may not be used at all.

    Using this function will disable attempts to use themes for this window, if the system supports them. Use with care since usually the themes represent the appearance chosen by the user to be used for all applications on the system.

    James

    There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014212]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-08-29 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls