beetlebug▾
/

ttk::button instate

Tests the state flags of the widget, and runs a script when they match.

PATHNAME instate STATESPEC ?SCRIPT?

Description

STATESPEC is a list of flags, each with an optional ! before it. The spec matches when each plain flag is on and each flag with ! is off. With no SCRIPT, gives 1 for a match and 0 for no match. With SCRIPT, runs it at the global level on a match and gives its result, else gives an empty string.

Returns

1 or 0, or the result of SCRIPT.

Examples

% ttk::button .tbis
> .tbis state disabled
> list [.tbis instate disabled] [.tbis instate !disabled]
1 0

% ttk::button .tbis2
> .tbis2 instate !disabled {list ok}
ok

Errors

% ttk::button .tbis3; .tbis3 instate
wrong # args: should be ".tbis3 instate state-spec ?script?"
-errorcode NONE

% ttk::button .tbis4; .tbis4 instate bogus
Invalid state name bogus
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also