#251 Allow tristate selection for ttk::checkbuttons

pending
Joe English
5
2013-03-18
2013-03-14
Talvo
No

At the moment, the only way to get a "tristate" appearance for a checkbutton is to manually unset the variable associated with the widget - it's impossible to get it by interacting with the widget. It would be nice if this was altered, either with
-tristate <bool>
which toggles whether clicking the checkbutton can put it into tristate mode (by unsetting the associated variable), probably the better way, or
-tristate <value>
which will toggle into tristate mode and set the variable to <value>. If -tristate isn't given, it would not be possible to click into tristate mode.

When -tristate is given, clicking the checkbutton would toggle it from on -> off -> tristate -> on -> ... etc, rather than just on -> off -> on -> ...

This would be useful for situations where something can be explicitly on, explicitly off, or ignored, for example when no input is given and the value should be checked on a parent instead.

Discussion

  • Joe English
    Joe English
    2013-03-17

    This is easily accomplished with modified widget bindings; see attached tricycle.tcl and edit to suit. See also $TK_LIBRARY/ttk/button.tcl for reference.

    Usage: [ttk::checkbutton .b -class Tricycle ...] to get a checkbutton that behaves as requested.

     
  • Joe English
    Joe English
    2013-03-17

    • status: open --> pending
     
  • Talvo
    Talvo
    2013-03-18

    Yeah, I already looked at doing it by modifying the bindings. Would be nice to have it included, though (even if just by including the code you linked in ttk/button.tcl and documenting the class).

     
  • Talvo
    Talvo
    2013-03-18

    • status: pending --> open
     
  • Joe English
    Joe English
    2013-03-18

    Bindings for three-state checkbutton

     
    Attachments
  • Joe English
    Joe English
    2013-03-18

    • status: open --> pending