NAME
Tk::Dressing - Set a theme in your widget.
SYNOPSIS
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Dressing;
use Tk::BrowseEntry;
my $TkDressing = new Tk::Dressing;
my $mw = new MainWindow( -title => "Dressing widget", );
$mw->minsize( 300, 100 );
my $BrowseEntryTheme = $mw->BrowseEntry(
-label => "Select a theme : ",
-state => 'readonly',
-choices => [ 'clear dressing', sort $TkDressing->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 /);
$BrowseEntryTheme->configure(
-browse2cmd => sub {
my $theme = $BrowseEntryTheme->Subwidget('entry')->get;
if ( $theme eq 'clear dressing' ) { $TkDressing->clear($mw); return; }
$TkDressing->design_widget(
-widget => $mw,
-theme => $theme,
);
},
);
MainLoop();
DESCRIPTION
Tk::Dressing allows you to set a theme in your widget 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.
$TkDressing = new Tk::Dressing
The new() method is the main constructor for the Tk::Dressing module.
# Create Tk::Dressing constructor
my $TkDressing = new Tk::Dressing;
clear
This method allow you to replace your last theme set by the default look and feel of your widget.
$TkDressing->clear( $Widget )
$TkDressing->clear($mw);
design_widget
Set the theme on your widget and its children.
$TkDressing->design_widget( -widget => $Widget, -theme => $ThemeName )
- -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
$TkDressing->design_widget(
-widget => $mw,
-theme => 'djibel',
);
get_all_theme
Get all the themes available and loaded in your widget.
my @all_themes = $TkDressing->get_all_theme;
get_current_theme
Get the theme in used in your widget.
my $current_theme = $TkDressing->get_current_theme;
get_default_theme_file
Get an .ini file of one of default themes of module.
$file = $TkDressing->get_default_theme_file($theme, $directory)
my $file = $TkDressing->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 $TkDressing->load_theme_file($theme, $theme_file); # Set it to e frame widget $TkDressing->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 choice between theme proposed. But it is important to Tk::Dressing to propose a lot of default themes then, your help is welcome. Send me an .ini file and the name of your theme by email address or through the web interface at : http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tk-Dressing and I will be add it in the module in a new release.
EXAMPLE
See the demo directory in the distribution to execute an example program using Tk::Dressing.
SEE ALSO
See Tk::CmdLine and 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:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2010 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.