• configbody tcl tk


    package require Itcl


    itcl::class sampleconf { ;# a sample class with a single public variable
        public variable publicv ;# this var is adjusted using the configure -publicv...
        constructor {} { }
        method setpublicv {dn} {
           set publicv "$dn"
           puts $dn
         }
        method shwopublicv {} {
           puts $publicv
         }
      }


    # create a sample instance of the class:
    set btn [sampleconf  h2]

    # directory configure in the class
    h2 configure -publicv "good"
    h2 shwopublicv


    # add a widiget configure for a variable
    # add a configbody for public variable  publicv
    itcl::configbody sampleconf::publicv  {tk_messageBox -message "Publicv in $this was set to $publicv by a configure command."}

    h2 configure -publicv "A new Value"

    # change the publicv by configure and you see a message box.

    h2 configure -publicv "The same old Value"

    h2 setpublicv "A value which is not sent via the configbody"

    # change the publicv again by configure and again you see a message box.
    h2 configure -publicv "Another Value"

  • 相关阅读:
    「WC2021」表达式求值
    [补]「WC2021」括号路径
    「CEOI2020」星际迷航
    「CEOI2018」斐波那契表示法
    CF913F
    CF1017G The Tree
    NOI2020 超现实树
    LOJ 6714 Stupid Product
    LOJ 575. 不等关系
    CF1267G
  • 原文地址:https://www.cnblogs.com/greencolor/p/2042140.html
Copyright © 2020-2023  润新知