hwtk::colorbutton - Button with popdown color pallet
hwtk::colorbutton - pathName ?option value? ...
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.
-clientdata, clientData, ClientData
-helpcommand, helpcommand, Command
Command-Line Name: -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-Line Name: -command
Database Name: command
Database Class: Command
A Tcl script to execute whenever the widget is invoked.
Command-Line Name: -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.
Command-Line Name: -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 HyperWorks Desktop, the color values are 1-based (1-64). Acceptable values are 0 and 1; default value is 0.
Command-Line Name: -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.
In addition to the standard configure, cget, identify, instate, and state commands, colorbutton supports the following additional widget commands:
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 colorbutton, or the settings specified in the arguments.
pathName invoke
Invokes the color button.
pathName set color
Sets the value of the colorbutton.
set dlg [hwtk::dialog .clrDlg]
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::Priv(integer) $i
set ::test::Priv(hexa) $color
set ::test::Priv(rgb) $rgb
}
}
frame $w.f2.f1 -width 50 -relief groove -borderwidth 2
grid [hwtk::label $w.f2.l0 -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.l1 -text "Color Integer"] [hwtk::entry $w.f2.e1 -textvariable ::test::Priv(integer) -state readonly] $w.f2.f1 -pady 4 -padx 4 -sticky w
grid [hwtk::label $w.f2.l2 -text "Color Hexa"] [hwtk::entry $w.f2.e2 -textvariable ::test::Priv(hexa) -state readonly] -pady 4 -padx 4 -sticky w
grid [hwtk::label $w.f2.l3 -text "Color RGB"] [hwtk::entry $w.f2.e3 -textvariable ::test::Priv(rgb) -state readonly] -pady 4 -padx 4 -sticky w
grid configure $w.f2.f1 -rowspan 3 -sticky news
# This will set the color for the button and invokes the user command
$w.f2.b configure -color 26;
$dlg post