Noah Petherbridge > Tk-Spectrum-0.02 > Tk::Spectrum

Download:
Tk-Spectrum-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Tk::Spectrum - A stylish color selection dialog.

SYNOPSIS ^

  use Tk::Spectrum;

  my $color = $mw->Spectrum (
    -title        => 'Pick a Color',
    -initialcolor => '#000000',
    -buttons      => [ 'Ok', 'Cancel' ],
    -preset       => [ $preset_colors ],
  );

  print "You chose $color\n";

DESCRIPTION ^

Tk::Spectrum is a stylish color selection dialog. It presents the user with a full color spectrum with which they can click and drag to select colors, as well as a form where they can select RGB and Hexadecimal color values. It also supports a "preset color list" similar to the Win32 native color dialog box. The program can define which colors go into this list.

Note: This module only knows how to deal with hexadecimal numbers. It's impossible from the end user's side to enter a non-hex value, but if your program uses colors by name and you try to use named colors in Tk::Spectrum, it will cause errors.

OPTIONS ^

The options supported by Tk::Spectrum are as follows:

-title

Specifies the title of the dialog box. The default is "Select Color".

-initialcolor

Define the initial/default color for the dialog box. If the user hits Cancel, the initial color is returned.

-buttons

Specify the labels for one or both of the buttons on the dialog box. If only one label is given, it's used on the "Ok" button. If two are given, they're used on "Ok" and "Cancel", respectively. The default values are "Ok" and "Cancel".

-preset

Define a preset color scheme. This takes a number of array references, one array representing each row of colors to use. The default range of preset colors are suitable for almost all situations. If your program really needs to override the presets, you can do so.

  -preset => [
    # Row 1
    [ '#FF0000', '#00FF00', '#0000FF' ],
    # Row 2
    [ '#990000', '#009900', '#000099' ],
  ],

You can have virtually as many rows and columns as you need, but keep in mind that the dialog window size may grow to accomodate.

CHANGES ^

  Version 0.02
  - Added dependency on Tk and Tk::PNG to Makefile.PL to stop CPAN's nagging

  Version 0.01
  - Initial release

AUTHOR ^

Casey Kirsle

This module is distributed under the same terms as Perl itself.

syntax highlighting: