hwtk::colorbutton

Button with popdown color pallet.

Format

hwtk::colorbutton - pathName ?option value? …

Description

A hwtk::colorbutton widget is a button which includes a popdown color pallet. The button itself contains no text, but shows the selected color. When clicked, the color pallet appears below the button, which shows the currently selected color (highlighted) and allows a new color to be chosen.

Standard Options

-clientdata
Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.
-help
Database name: help
Database class: Text
Specifies the text or help message that displays when the cursor moves over the widget.
-helpcommand
Database name: helpcommand
Database class: Command
Dynamic help which calls an assigned -helpcommand when the user moves the mouse on the widget. The text which is returned by the -helpcommand will be in turn be displayed on the tooltip.
-state
Database name: state
Database class: State
May be set to normal or disabled to control the disabled state bit.
-takefocus
Database name: takeFocus
Database class: TakeFocus
Determines whether the window accepts the focus during keyboard traversal. Either 0, 1, a command prefix (to which the widget path is appended, and which should return 0 or 1), or the empty string. See options(n) in the Tk reference manual for the full description.

Widget-Specific Options

-color
Database name: color
Database class: Color
The selected color in the color pallet, which is displayed by the color button itself. Can be given as an integer, hexadecimal, or RGB value.
-command
Database name: command
Database class: Command
A script to evaluate when the widget is invoked.
-padding
Database name: padding
Database class: Pad
Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications left, top, right, bottom. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left.
-startindex
Database name: startindex
Database class: Index
Specifies the start index for the color values. In HyperMesh, the color values are 0-based (from 0-63), whereas in HyperMesh Desktop, the color values are 1-based (1-64). Acceptable values are 0 and 1; default value is 0.
-values
Database name: values
Database class: Values
Specifies the colors to be displayed in the dropdown color pallet. By default, all 64 colors are shown, but if the user wants only a subset of colors to be shown, a list of color values can be specified using this option. Acceptable values which can be included in the list are integers from 0-63 or 1-64, depending on the value specified by -startindex.

Widget Command

pathName configure ?option? ?value option value …?
Query or modify the configuration options of the widget. If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
pathName cget option
Returns the current value of the configuration option given by option.
pathName identify element x y
Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
pathName instate statespec ?script?
Test the widget’s state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
if{[pathNameinstatestateSpec]}script
pathName state ?stateSpec?
Modify or inquire widget state. If stateSpec is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Returns a new state spec indicating which flags were changed:
setchanges[pathNamestatespec]
pathNamestate$changes
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
pathName color ?index
Sets the value of the colorbutton to the color given by index. Acceptable values are 1-64. If no index is given, this command returns the current value of the colorbutton.
pathName get ?arg arg...?
Gets the value of the color button, or the settings specified in the arguments.
pathName invoke
Invokes color button.
pathName set color
Sets the value of the color button.

Example

::hwtk::dialog .dlg -title "::hwtk::colorbutton" -height 8
set w [.dlg recess]

pack [hwtk::labelframe $w.f2 -text "colorbutton"] -anchor nw -pady 10 -padx 10 

namespace eval ::test {
    proc SetColor {F i color rgb} {
        $F configure -background $color
        set ::test::Prive(integer) $1
        set ::test::Prive(hexa) $color
        set ::test::Prive(rgb) $rgb
}
frame $w.f2.f1 -width 50 -relief groove -borderwidth 2
grid[hwtk::label $w.f2.10 -text "Color Button"][hwtk::colorbutton $w.f2.b -color 16 -command "::test::SetColor $w.f2.f1 %I %H {%R}"] -pady 4 -padx 4 -sticky w   
grid[hwtk::label$w.f2.11 -text "Color Integer"][hwtk::entry $w.f2.e1 -textvariable ::test::Prive(integer) -state readonly]  $w.f2.f1 -pady 4 -padx 4 -sticky w 
grid[hwtk::label$w.f2.12 -text "Color Hexa"][hwtk::entry $w.f2.e2 -textvariable ::test::Prive(hexa) -state readonly] -pady 4 -padx 4 -sticky w 
grid[hwtk::label$w.f2.13 -text "Color RGB"][hwtk::entry $w.f2.e3 -textvariable ::test::Prive(rgb) -state readonly] -pady 4 -padx 4 -sticky w 
grid configure $w.f2.f1 -rowspan 3 -stickynews

# This will set the color for the button and invokes the user command

$w.f2.b configure -color 26;

.dlg post