Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/self/root/usr/share/doc/perl-Tk/demos/widget_lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/root/usr/share/doc/perl-Tk/demos/widget_lib/clrpick.pl
# clrpick.pl

use Tk qw/catch/;
use subs qw/setColor setColor_helper/;
use vars qw/$TOP/;

sub clrpick {
    my($demo) = @_;
    $TOP = $MW->WidgetDemo(
        -name             => $demo,
        -text             => 'Press the buttons below to choose the foreground and background colors for the widgets in this window.',
        -title            => 'chooseColor Demo',
        -iconname         => 'chooseColor',
    );

    my(@pl) = qw/-side top -anchor c -pady 2m/;
    my($back, $front);
    $back = $TOP->Button(-text => 'Set background color ...')->pack(@pl);
    $back->configure(-command => [\&setColor => $TOP, $back, '-background',
		      [-background, -highlightbackground]]);
    $front = $TOP->Button(-text => 'Set foreground color ...')->pack(@pl);
    $front->configure(-command => [\&setColor => $TOP, $front, '-foreground',
		      [-foreground]]);
}

sub setColor {
    my($top, $button, $name, $options) = @_;
    my $initialColor = $button->cget($name);
    my $color = $button->chooseColor(-title => "Choose a $name color",
				     -initialcolor => $initialColor);
    setColor_helper $top, $options, $color if defined $color;
}

sub setColor_helper {
    my($widget, $options, $color) = @_;
    foreach my $option (@$options) {
	catch {
	    $widget->configure($option => $color);
	}
    }
    foreach my $child ($widget->children) {
	setColor_helper $child, $options, $color;
    }
}


Hry