Path: nntp.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Mark Summerfield Newsgroups: comp.lang.tcl Subject: Re: How to set ttk::radiobutton -variable to an object's instance variable? Date: Fri, 11 Jul 2025 15:21:52 -0000 (UTC) Organization: A noiseless patient Spider Lines: 37 Message-ID: <104ra6g$1iid4$1@dont-email.me> References: <104qn2d$1ef5l$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 11 Jul 2025 17:21:53 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e32decfb73d297d3d591871b6e8a834f"; logging-data="1657252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gvy4h6nLqDBSPjPi7U2wp" User-Agent: Pan/0.154 (Izium; 517acf4) Cancel-Lock: sha1:Rgqcac53RbZ00MIoC0+dzM0qpQg= On Fri, 11 Jul 2025 13:28:06 +0200, Schelte wrote: > On 11/07/2025 11:55, Mark Summerfield wrote: >> Given this class: >> >> oo::class create App { >> # ... >> variable ShowState >> } >> >> And this method: >> >> oo::define App method make_controls {} { >> # ... >> ttk::radiobutton .controlsFrame.showFrame.asIsRadio \ >> -text "Show as-is" -value asis -variable ShowState >> set ShowState asis >> >> The variable given to the radio button and the instance variable >> are_different_. > > ttk::radiobutton .controlsFrame.showFrame.asIsRadio \ > -text "Show as-is" -value asis -variable [my varname ShowState] > > > Schelte. That silently didn't work. I also tried `-variable [my variable ShowState]` and that didn't work either. I don't use snit so I couldn't use that approach either. Given that Tcl 9 has the incredibly useful `callback` command which I use all the time with Tk widgets for their `-command` options, I'm surprised there isn't an equivalent for Tk widget variables: or perhaps there is and I haven't found it?