Re: How to set ttk::radiobutton -variable to an object's instance? variable?

Liste des GroupesRevenir à cl tcl 
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.tcl
Date : 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-5364
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services

Date Sujet#  Auteur
11 Jul 25 * How to set ttk::radiobutton -variable to an object's instance variable?6Mark Summerfield
11 Jul 25 +- Re: How to set ttk::radiobutton -variable to an object's instance? variable?1Robert Heller
11 Jul 25 `* Re: How to set ttk::radiobutton -variable to an object's instance variable?4Mark Summerfield
12 Jul 25  +* Re: How to set ttk::radiobutton -variable to an object's instance variable?2Emiliano
12 Jul 25  i`- Re: How to set ttk::radiobutton -variable to an object's instance variable?1et99
14 Jul 25  `- Re: How to set ttk::radiobutton -variable to an object's instance variable?1Mark Summerfield

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal