Sujet : Re: How to set ttk::radiobutton -variable to an object's instance? variable?
De : heller (at) *nospam* deepsoft.com (Robert Heller)
Groupes : comp.lang.tclDate : 11. Jul 2025, 11:09:44
Autres entêtes
Organisation : Deepwoods Software
Message-ID : <104qnt8$1epce$1@dont-email.me>
References : 1
User-Agent : TkNews 3.0 (1.2.20)
At Fri, 11 Jul 2025 09:55:25 -0000 (UTC) Mark Summerfield <
m.n.summerfield@gmail.com> 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_.
I tried these variations, all of which gave errors:
-variable [my ShowState]
-variable [my $ShowState]
-variable [self ShowState]
-variable [self $ShowState]
For now I'm using a global variable ::ShowState
but I'd really like it to be an instance variable -
if it can be done?
I don't know anything about how Tcl OO system works, but with SNIT I can do
this:
package require snit
package require Tk
snit::widget foo {
variable ShowState
constructor {args} {
# ...
ttk::radiobutton $win.controlsFrame.showFrame.asIsRadio \
-text "Show as-is" -value asis -variable [myvar ShowState]
# ...
}
}
-- Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364Deepwoods Software -- Custom Software Serviceshttp://www.deepsoft.com/ -- Linux Administration Servicesheller@deepsoft.com -- Webhosting Services