[HOME][CONTENTS][DOWNLOAD][PREV][NEXT]


COMB WIDGET EXAMPLES

Palette. Palette is a comb-widget that is used for color selection. It has a palette for a user to pick up a pre-defined color and three num widgets to edit red, green and blue components of a specific color. 

EXAMPLE: The following example creates a frm and then adds a pal widget into it. Each num of the created pal widget is bound to a script that prints the current color definition. 

catch "destroy .pal"
toplevel .pal
set frm [frm.create .pal.frm -label {-text Palette}]
set pal [frm.add $frm -pal pal.create]
foreach num {r g b} {
    num.bindChange [comb.id $pal \
        -$num] "puts \[pal.get $pal\]" 
}
pack $frm -expand 1 -fill both
pack $pal -expand 1 -fill both -pady 2

An example of a pal widget 

CLASS NAME: pal

COMB-WIDGET OPTIONS

-r options It specifies options of a num widget to edit a red component of a color definition. 
-g options It specifies options of a num to edit a green component of a color definition. 
-b options It specifies options of a num to edit a blue component of a color definition. 
WIDGET API
pal.create pathname ?options? This command creates a pal widget that consists of three num widgets and an array of palette objects. Clicking a palette object will set the values of the three numeric thumbs for a RGB definition of that palette. A RGB color definition can also be configured by increasing or decreasing the values of the three RGB thumbs. 
pal.config pathname ?options? This command configures sub-widgets of a pal referred to by pathname
pal.cget pathname -varName This command retrieves the options of a sub-widget of pal referred to by pathname
pal.bind pathname event scripts -varName This command binds an event of a pal's sub-widget referred to by -varName to scripts
pal.get pathname This command retrieves the RGB definition of a pal widget. The returned value is in a format "#rrggbb". 
pal.set pathname color This command sets the color definition of a pal widget. The color is a Tk color definition that can be parsed by the command winfo rgb
pal.update pathname args This command is a wrap up of the command: eval $args [pal.get pathname]. 
RELATED PROCEDURES

The followings are procedures used in pal widget implementation and test. A user may access to these procedures through the pal widget API, and should never use these procedures directly in an application program. 

pal.bw n
pal.colors pathname nx ny colors
pal.free pathname
pal.rgb nr ng nb
pal.test pathname 
[HOME][CONTENTS] [DOWNLOAD]
1