NAME

Tk::Dressing - Set a theme (dressing) in your widget and its children.

SYNOPSIS

#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Dressing;

use Tk::BrowseEntry;

my $tk_dressing = Tk::Dressing->new();

my $mw = MainWindow->new( -title => "Dressing widget", );
$mw->minsize( 300, 100 );

$mw->Button( -text => 'Close', )->pack(qw/ -side bottom -padx 10 -pady 10 /);

my $browse_entry_theme = $mw->BrowseEntry(
  -label   => "Select a theme : ",
  -state   => 'readonly',
  -choices => [ 'clear dressing', sort $tk_dressing->get_all_theme ],
)->pack;

my $message = "Hello everybody\n\nWelcome to Perl/Tk and Tk::Dressing\n\n";
$mw->Label( -text => $message,     -anchor => 'center' )->pack(qw/ -side top -padx 10 -pady 10 /);
$mw->Label( -text => 'Example : ', -anchor => 'center' )->pack(qw/ -side left -padx 10 -pady 10 /);
$mw->Entry( -text => 'test', )->pack(qw/ -side left -padx 10 -pady 10 /);

$browse_entry_theme->configure(
  -browse2cmd => sub {
    my $theme = $browse_entry_theme->Subwidget('entry')->get;
    if ( $theme eq 'clear dressing' ) { $tk_dressing->clear($mw); return; }
    $tk_dressing->design_widget(
      -widget => $mw,
      -theme  => $theme,
    );
  },
);

MainLoop();

DESCRIPTION

Tk::Dressing allows you to set a theme (dressing) in your widget and its children by using one of different default themes or by loading a new theme. A theme contains all options that you want to use to configure the Tk widgets (color of buttons, of Entry, ...).

Everybody can participate to increase the themes of this module by proposing a theme that will be store in the module because each theme is stored in an ini file.

CONSTRUCTOR/METHODS

new

This constructor allows you to create a new Tk::Dressing object.

$tk_dressing = Tk::Dressing->new()

The new() method is the main constructor for the Tk::Dressing module.

# Create Tk::Dressing constructor
my $tk_dressing = Tk::Dressing->new();

clear

This method allow you to replace your last theme set by the default look and feel of your widget.

$tk_dressing->clear( $widget )

$tk_dressing->clear($mw);

design_widget

Set the theme (dressing) on your widget and its children.

$tk_dressing->design_widget( -widget => $widget, -theme => $theme_name )

-widget => $widget

Specifies the widget. The widget can be a Toplevel, Frame, Button, ...

-widget => $mw,
-theme => string

Specifies the theme name between defaults themes of module. If you have loaded a theme before, you can choose it.

-theme => 'starwars',

Default : djibel

$tk_dressing->design_widget(
 -widget => $mw,
 -theme  => 'djibel',
);

get_all_theme

Get all the available themes and loaded in your widget.

my @all_themes = $tk_dressing->get_all_theme;

get_current_theme

Get the theme in used in your widget.

my $current_theme = $tk_dressing->get_current_theme;

get_default_theme_file

Get an .ini file of one of default themes of module.

$file = $tk_dressing->get_default_theme_file($theme, $directory)

my $file = $tk_dressing->get_default_theme_file('djibel', '/home/user');
# $file will be contain /home/user/djibel.ini and this file will be create.

load_theme_file

Loads your own theme file to design your widget.

# Load your file
$tk_dressing->load_theme_file($theme, $theme_file);
# Set it to e frame widget
$tk_dressing->design_widget(
 -widget => $frame,
 -theme  => $theme,
);

Your file must be an .ini file and must contain sections. Each section correspond to a widget, that is an example.

[BrowseEntry]
-background: #697E6D
-foreground: white
-disabledbackground: #697E6D
-disabledforeground: white

[Button]
-activebackground: #7F80C0
-background: #7F80C0
-foreground: white
-disabledforeground: white
-activeforeground: white

[Canvas]
-background: #697E6D

[Checkbutton]
-highlightbackground: #68676C
-activebackground: #68676C
-background: #68676C
-foreground: white
-disabledforeground: white
-activeforeground: white
-selectcolor: #697E6D

[ColoredButton]
-highlightbackground: #68676C
-background: #68676C
-autofit: 1

[DirTree]
-highlightbackground: #68676C
-background: #697E6D
-foreground: white
-highlightcolor: #68676C
-selectforeground: white
-selectbackground: #68676C

[Entry]
-highlightbackground: #68676C
-background: #697E6D
-disabledbackground: #697E6D
-foreground: white
-readonlybackground: #697E6D
-disabledforeground: white
-insertbackground: white

How to participate to module to increase number of default themes ?

The first aim of Tk::Dressing is to allow user to choose between the proposed theme. But it is important for Tk::Dressing to propose a lot of default themes then, your help is welcome.

Send me a .ini file and the name of your theme by email or through the web interface at : http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tk-Dressing. I will add it in the module in a new release. It will be notified in Change file.

EXAMPLE

See the demo directory in the distribution to execute an example program using Tk::Dressing.

SEE ALSO

See "NAME" in Tk::CmdLine and "NAME" in Tk::Preferences.

AUTHOR

Djibril Ousmanou, <djibel at cpan.org>

BUGS

Please report any bugs or feature requests to bug-tk-dressing at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tk-Dressing. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Tk::Dressing

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Djibril Ousmanou.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.