usual

class cc {
 inherit itk::Widget
 public method changtext 
 #array aar
 itk_option define -textbackground textBackground Background "\#ff0000"
 
 constructor {args} {
 itk_component add linetwo {
    button $itk_component(hull).d \
            -text "bbb"
 }
  
 itk_component add buttontwo {
    button $itk_component(hull).b \
            -text "est" \
            -command "$itk_component(hull) changtext ccc"
 } {
  usual
     keep -text
 }
  
 pack $itk_component(linetwo)
 pack $itk_component(buttontwo)
 }
}

body cc::changtext { args } {
 #set aar[1] 0;
 #puts $aar[1]
 .c.d configure -text $args
 .c.b configure -text $args
}


cc .c
pack .c

can not change buttontwo

====================================

class cc {
 inherit itk::Widget
 public method changtext 
 #array aar
 itk_option define -textbackground textBackground Background "\#ff0000"
 
 constructor {args} {
 itk_component add linetwo {
    button $itk_component(hull).d \
            -text "bbb"
 }
  
 itk_component add buttontwo {
    button $itk_component(hull).b \
            -text "est" \
            -command "$itk_component(hull) changtext ccc"
 } {
  usual 
     ignore -text
 }
  
 pack $itk_component(linetwo)
 pack $itk_component(buttontwo)
 }
}

body cc::changtext { args } {
 #set aar[1] 0;
 #puts $aar[1]
 .c.d configure -text $args
 .c.b configure -text $args
}


cc .c
pack .c


buttontwo can be changed

原文地址:https://www.cnblogs.com/greencolor/p/2133698.html