chooseColor(3) User Contributed Perl Documentation chooseColor(3)

# [NAME](#NAME)

Tk::chooseColor - pops up a dialog box for the user to select a color.

# [SYNOPSIS](#SYNOPSIS)

    *$color* = *$widget*-&gt;**chooseColor**?(*-option*=&gt;*value*, ...)?;

# [DESCRIPTION](#DESCRIPTION)

The method **chooseColor** is implemented as a perl wrapper on the core tk "command" **tk\_chooseColor**, and *$widget* is passed as the argument to the hidden **-parent** option. The implementation of internal **tk\_chooseColor** is platform specific, on Win32 it is a native dialog, and on UNIX/X11 it is implemented in terms of Tk::ColorEditor.

The **chooseColor** method pops up a dialog box for the user to select a color. The following *option-value* pairs are possible as command line arguments:

[**-initialcolor**=&gt;*color*](#initialcolor)

Specifies the color to display in the color dialog when it pops up. *color* must be in a form acceptable to the **Tk\_GetColor** function.

[**-parent**=&gt;$widget](#parent)

Makes $widget the logical parent of the color dialog. The color dialog is displayed on top of its parent window.

[**-title**=&gt;*titleString*](#title)

Specifies a string to display as the title of the dialog box. If this option is not specified, then a default title will be displayed.

If the user selects a color, **tk\_chooseColor** will return the name of the color in a form acceptable to **Tk\_GetColor**. If the user cancels the operation, the command will return **undef**.

# [EXAMPLE](#EXAMPLE)

```
 $widget->configure(-fg => $parent->chooseColor(-initialcolor => 'gray',
                                                -title => "Choose color"));
```

# [KEYWORDS](#KEYWORDS)

color selection dialog

2026-10-26 perl v5.44.0

---

Document: Tk::chooseColor(3pm) from perl-tk 804.036-r13 (Chainguard OS)
Source: https://github.com/eserte/perl-tk
