| Itcl  | Itk  | Itcl @ Wiki  | Itcl @ SF  | Tcl  | Tcl @ Wiki |
  home iwidgets man pages cross ref distribution docs || faq ||  


Frequently Asked Questions (FAQ)


    1. What is the most current version of Iwidgets?
    2. What versions of Itcl include Iwidgets?
    3. Why is Iwidgets distributed independently as well as along with Itcl?
    4. How do I access the options database for Iwidgets?
    5. How do I inherit options/public variables with Itk/Iwidgets?
    6. How can I generate a new tclIndex file with new iwidgets that I have added?
    7. How can I access the bindings of the components of Iwidgets?




    1. What is the most current version of Iwidgets?
The latest version of Iwidgets is 4.0.0, which is compatable with Itcl 3.2. This is a significant release, because Iwidgets has been separated from the main core, so that it can stand on its own.

    2. What versions of Itcl include Iwidgets?
Each release of Itcl, version 2.0 or higher will include the latest version of Iwidgets. The Iwidgets mega-widget set is not compatabile with Itcl 1.5.

    3. Why is Iwidgets distributed independently as well as along with Itcl?
It is anticipated that Iwidgets will change more rapidly than Itcl. This being the case, the latest Itcl release will include the latest Iwidgets. Following that, as modifications, enhancements, and editions are made to Iwidgets, independent releases will be made available at the distribution site

    4. How do I access the options database for Iwidgets?
The Iwidgets work just like the Tk widgets, except that they have lots more configuration options. Sometimes the options are renamed for a particular component widget, so that it behaves correctly with the other component widgets. Hence, you will need to query the options for the Iwidget in order to get the correct options. Here is a script that will build a series of 'option add' statements for a particular widget (from a Michael McLennan posting):
set class [winfo class $widget]
foreach opt [$widget configure] {
  set resname [lindex $opt 1]
  set init [lindex $opt 3]
  puts [list option add *$class.$resname $init]
}

where $widget is the name of the widget that you are querying.


    5. How do I inherit options/public variables with Itk/Iwidgets?
When you're dealing with a mega-widget class, you should create mega-widget options instead of public variables. In theory, the public variables should work (in case they come from a mix-in class), but they don't quite work right. This isn't much of a problem, because most people use the "itk_option define" instead of public variables in their mega-widgets, as shown below:

package require Iwidgets

class BottomClass {

  inherit itk::Widget

  itk_option define -charlie charlie Charlie "" {
    puts "new value for -charlie: $itk_option(-charlie)"
  }
         
  constructor {args} {
    eval itk_initialize $args

    puts "Charlie is -->$itk_option(-charlie)<--"
    puts "Charlie is -->[$this cget -charlie]<--"
  }
         
}
         
         
class TopClass {
         
  inherit BottomClass
         
  constructor {args} {
    eval itk_initialize $args
  }
         
}
         
         
BottomClass .bc
         
         
TopClass .tc
         
         
TopClass .tc2 -charlie "Second"

Note that each "itk_option define" has three names for an option: the switch name (-charlie), the resource name (charlie), and the resource class (Charlie). The resource name/class are useful for "option add" statements. The plain public variable declaration doesn't have room for source name/class info. That's why you're supposed to use "itk_option define" for mega-widgets. (from a Michael McLennan posting)


    6. How can I generate a new tclIndex file with new iwidgets that I have added?
In order to generate a new tclindex, so that a new iwidgets is recognized, then you need to do a package require Iwidgets before you invoke auto_mindex.

    7. How can I access the bindings of the components of Iwidgets?
You need to use the component method in the binding. For example, in the pushbutton iwidgets, to bind the actually button that is part of the pushbutton Iwidget, you need to do something like the following:

       
iwidgets::pushbutton .pb -text "test"  
set comp [.pb component pushbutton] ;# note that pushbutton is the button component       
focus $comp       
bind $comp <Return> ".pb invoke"       

 
  home iwidgets man pages cross ref distribution docs || faq ||  
Copyright | Contributions | Development Team | Credits
Bugs/Comments/Suggestions about this web site