NAME

die - A Dmhwidget for depicting dice

SYNOPSIS

dmhwidgets::die pathName ?options?

INHERITANCE

itk::Widget <- dmhwidgets::Die

STANDARD OPTIONS

activebackground activeforeground background font foreground

See the options manual entry for details on the standard options.

WIDGET-SPECIFIC OPTIONS

Name: flash  Class: Flash  Command-Line Switch: -flash  Default value: 1

The value is used as a boolean to determine if the die should flash when the show method is called to display a value.

DESCRIPTION

The die command creates a widget that represents the face of a die, and a new Tcl command whose name is pathname. The command is then used to invoke various methods of the widget. The command has the general form:

pathName option ?arg arg ... arg?

The die is implemented as a button. The default button action is to invoke the roll method.

The button action can be changed by configuring the -command option of the bdie component. (For example, pathName component bdie configure -command newCommand.) The die depiction is based on displayed characters for the button text. A larger or smaller die can be obtained by configuring a larger or smaller fixed pitch font for the widget.

WIDGET-SPECIFIC METHODS

pathName roll
Show a random die face from 1 to 6. The return value is the chosen face value.
pathName show N
Display the die face for the value N. The value 0 displays a blank face.
pathName value
Return the numeric value corresponding to the displayed face.

EXAMPLE

package require Dmhwidgets

frame .dice 
pack .dice -side top -expand 1 -fill both

dmhwidgets::die .dice.d1
dmhwidgets::die .dice.d2
pack .dice.d1 .dice.d2 -side left -expand 0  -padx 10 -pady 10

button .diceb -text Roll -command dice_roll -width 8
pack .diceb -side top -padx 12m -pady 4m

proc dice_roll {} {
    .diceb configure -state disabled
    set sum 0
    foreach d [list .dice.d1 .dice.d2] {
        incr sum [$d roll]
        }
    .diceb configure -state normal
    return $sum
    }

AUTHOR

Hume Integration Software, www.hume.com

KEYWORDS

dice, simulation, widget