Version 1 of ttk::button

Updated 2008-03-04 18:39:06 by bryan

Ttk's button widget.

Note that on Windows XP, this widget looks much better than the default.


The ttk::button widget behavior deviates from normal Tk buttons in one critical way: when you click a ttk::button widget the keyboard focus goes to that widget. With plain Tk buttons this does not happen. This, I think, is a significant change in behavior. For example, imagine being in a text editor and clicking on a toolbar button -- you don't want focus to leave the text widget, and you don't want to have to add in the binding for every button to restore the focus.

To work around this you can set -takefocus to zero but then you lose the benefit of keyboard traversal which isn't good for accessibility.

The workaround I've started using is to simply change the class bindings. The original bindings call ttk::clickToFocus, which I think can be safely removed. The new class binding becomes:

 bind TButton <ButtonPress-1> {%W state pressed}

Changing the state is critical; without it the button becomes effectively disabled.