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


  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 ],
  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 /);
    -browse2cmd => sub {
      my $theme = $browse_entry_theme->Subwidget('entry')->get;
      if ( $theme eq 'clear dressing' ) { $tk_dressing->clear($mw); return; }
        -widget => $mw,
        -theme  => $theme,


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.



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();


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

$tk_dressing->clear( $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

   -widget => $mw,
   -theme  => 'djibel',


Get all the available themes and loaded in your widget.

  my @all_themes = $tk_dressing->get_all_theme;


Get the theme in used in your widget.

  my $current_theme = $tk_dressing->get_current_theme;


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.


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
   -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.

  -background: #697E6D
  -foreground: white
  -disabledbackground: #697E6D
  -disabledforeground: white
  -activebackground: #7F80C0
  -background: #7F80C0
  -foreground: white
  -disabledforeground: white
  -activeforeground: white
  -background: #697E6D
  -highlightbackground: #68676C
  -activebackground: #68676C
  -background: #68676C
  -foreground: white
  -disabledforeground: white
  -activeforeground: white
  -selectcolor: #697E6D
  -highlightbackground: #68676C
  -background: #68676C
  -autofit: 1
  -highlightbackground: #68676C
  -background: #697E6D
  -foreground: white
  -highlightcolor: #68676C
  -selectforeground: white
  -selectbackground: #68676C
  -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 : I will add it in the module in a new release. It will be notified in Change file.


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


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


Djibril Ousmanou, <djibel at>


Please report any bugs or feature requests to bug-tk-dressing at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


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

    perldoc Tk::Dressing

You can also look for information at:



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 for more information.