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
- -help
- Database name: help
- -helpcommand
- Database name: helpcommand
- -state
- Database name: state
- -takefocus
- Database name: takeFocus
Widget-Specific Options
- -color
- Database name: color
- -command
- Database name: command
- -padding
- Database name: padding
- -startindex
- Database name: startindex
- -values
- Database name: values
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:
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.setchanges[pathNamestatespec]
pathNamestate$changes
- 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