Next / Previous / Contents

46.1. Specifying widget states in ttk

Several methods within ttk require a stateSpec argument that specifies a particular widget state or combination of states. This argument may be any of the following:

  • A single state name such as 'pressed'. A ttk.Button widget is in this state, for example, when the mouse cursor is over the button and mouse button 1 is down.

  • A single state name preceded with an exclamation point (!); this matches the widget state only when that state is off.

    For example, a stateSpec argument '!pressed' specifies a widget that is not currently being pressed.

  • A sequence of state names, or state names preceded by an '!'. Such a stateSpec matches only when all of its components match. For example, a stateSpec value of ('!disabled', 'focus') matches a widget only when that widget is not disabled and it has focus.