itk_option remove

itk_option remove optName ?optName optName ...?
Removes one or more options from the composite option list for a mega-widget. Here, optName can have one of the forms described above for the "itk_option add" command.
Options are normally integrated into the composite option list when a component widget is first created. This method can be used to remove options at a later time. For example, a derived class can override an option defined in a base class by removing and redefining the option:
itcl::class Base {
    inherit itk::Widget
    constructor {args} {
        eval itk_initialize $args
    }

    itk_option define -foo foo Foo "" {
        puts "Base: $itk_option(-foo)"
    }
}

itcl::class Derived {
    inherit Base

    constructor {args} {
        itk_option remove Base::foo
        eval itk_initialize $args
    }
    itk_option define -foo foo Foo "" {
        puts "Derived: $itk_option(-foo)"
    }
}
Without the "itk_option remove" command, the code fragments for both of the "-foo" options would be executed each time the composite "-foo" option is configured. In the example above, the Base::foo option is suppressed in all Derived class widgets, so only the Derived::foo option remains.
posted @ 2011-06-16 22:25  greencolor  阅读(232)  评论(0编辑  收藏  举报