- component.option
- Accesses an option belonging to a component with the symbolic name component. The option name is specified without a leading "-" sign.
- className::option
- Accesses an option defined by the "itk_option define" command in class className. The option name is specified without a leading "-" sign.
Options are normally integrated into the composite option list when a component widget is first created. This method can be used to add options at a later time. For example, the Widget and Toplevel base classes keep only the bare minimum options for their "hull" component: -background and -cursor. A derived class can override this decision, and add options that control the border of the "hull" component as well:
itcl::class MyWidget { inherit Widget constructor {args} { itk_option add hull.borderwidth hull.relief itk_component add label { label $itk_interior.l1 -text "Hello World!" } pack $itk_component(label) eval itk_initialize $args } }
- itk_option define switchName resourceName resourceClass init ?config?
- This command is used at the level of the class definition to define a synthetic mega-widget option. Within the configure and cget methods, this option is referenced by switchName, which must start with a "-" sign. It can also be modified by setting values for resourceName and resourceClass in the X11 resource database. The init value string is used as a last resort to initialize the option if no other value can be used from an existing option, or queried from the X11 resource database. If any config code is specified, it is executed whenever the option is modified via the configure method. The config code can also be specified outside of the class definition via the configbody command.
In the following example, a synthetic "-background" option is added to the class, so that whenever the background changes, the new value is reported to standard output. Note that this synthetic option is integrated with the rest of the "-background" options that have been kept from component widgets:itcl::class MyWidget { inherit Widget constructor {args} { itk_component add label { label $itk_interior.l1 -text "Hello World!" } pack $itk_component(label) eval itk_initialize $args } itk_option define -background background Background #d9d9d9 { puts "new background: $itk_option(-background)" } }
- 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)" } }