From: Emiliano on
Widget states are pretty different on ttk than the ones on plain Tk.
See http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_widget.htm#M22

The easiest way to obtain the behaviour you want is turning off
all widget bindings

set var 1
ttk::checkbutton .cb -variable var -onvalue 1 -offvalue 1
pack .cb
bindtags .cb {NONE}

The .cb checkbutton will not respond to any of the standards bindings,
behaving as read only. However, it still reflects the value of the
associated variable.

Emiliano
From: Joe English on
jmc wrote:
>
> I would like to know if the ttk_checkbutton widget can be configured
> with the "-state readonly" option.


It can, but that doesn't have any effect.

The preferred way to change the state of ttk::* widgets
is with the [$w state] command (the "-state" option is
only present as a compatibility shim).

However, ttk::checkbuttons and radiobuttons don't support
the "readonly" state, so [$cb state readonly] won't work
anyway.

The best way to get an "output-only" checkbutton
(or to change the behavior in general) is to use
a different widget class:

[ttk::checkbutton .cb -class ROCheckbutton]

Then add the appropriate bindings for the ROCheckbutton
bindtag. In this case, there are none, so do nothing :-)


--JE
From: jmc on
On 8 mai, 19:01, Joe English <jengl...(a)fdip.bad-monkeys.com> wrote:
> jmc wrote:
>
> > I would like to know if the ttk_checkbutton widget can be configured
> > with the "-state readonly" option.
>
> It can, but that doesn't have any effect.
>
> The preferred way to change the state of ttk::* widgets
> is with the [$w state] command (the "-state" option is
> only present as a compatibility shim).
>
> However, ttk::checkbuttons and radiobuttons don't support
> the "readonly" state, so [$cb state readonly] won't work
> anyway.
>
> The best way to get an "output-only" checkbutton
> (or to change the behavior in general) is to use
> a different widget class:
>
>     [ttk::checkbutton .cb -class ROCheckbutton]
>
> Then add the appropriate bindings for the ROCheckbutton
> bindtag.  In this case, there are none, so do nothing :-)
>
> --JE

Thanks everybody for your advice and explanation. Now the picture gets
a lot clearer to me.

Jean-Marie