http://www.perlmonks.org?node_id=1014252

perllee has asked for the wisdom of the Perl Monks concerning the following question:

Hi:

In Tk how to set the color of the scroll bar? windows XP.

I tried some options, but failed.

$lb = $mw->Scrollbar(-background=>'green',-troughcolor=>'blue');

Thanks.

  • Comment on In Tk how to set the color of the scrollbar?

Replies are listed 'Best First'.
Re: In Tk how to set the color of the scrollbar?
by zentara (Archbishop) on Jan 20, 2013 at 09:43 UTC
    This works on Linux:
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); my $text_box = $mw->Scrolled("Text", -scrollbars => 'osoe', -relief => 'sunken', -takefocus => 1) ->pack(-expand => 1, -fill => 'both'); for(1..1000){ $text_box->insert('end', "$_ test\n"); $text_box->see('end'); } $text_box -> Subwidget("yscrollbar")->configure( -background => "lightgreen", -troughcolor => "black", -command => \&scrollcallback, ); MainLoop; #if you specify a scrollcallback, you will override the #normal scroll behavior. sub scrollcallback{ #restore original function $text_box->yview(@_); #do your stuff here print "1\n"; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Naturally it doesn't actually change the colors on winxp, it changes the attributes, the colors remain the same
Re: In Tk how to set the color of the scrollbar?
by BrowserUk (Patriarch) on Jan 20, 2013 at 05:02 UTC

    Tk options start with a minus sign. Eg. -background => 'green' etc.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm sorry, typesetting errors.But the problem is still not solved.

        You'll be more likely to get help if you post a small, but working program that demonstrates the problem.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        In the absence of evidence, opinion is indistinguishable from prejudice.