Next: Setting the Styles Up: Creating Display Items Previous: Creating Display Items

 

Creating Display Items 

Now it's time to put our knowledge about host widgets, display items and display styles into practice. The following example code creates two items in a TixTList widget using the insert method:

tixTList .t
pack .t

.t insert end -itemtype text -text "First Item" -underline 0
.t insert end -itemtype text -text "Second Item" -underline 0

set picture [image create bitmap -file picture.xbm]
.t insert end -itemtype image -image $picture

As we can see, the insert method of TixTList is very similar to the insert method of the standard Tk listbox widget: it inserts a new item into the TixTList widget. The first argument it takes is the location of the new item. For example 0 indicates the first location in the list, 1 indicates the second location, and so on. Also the special keyword end indicates the end of the list.

Then, we can use the -itemtype switch to specify the type of display item we want to create. There are currently four types of items to choose from: text, image, imagetext and window. In the above example, we create two items of the type text and one item of the type image. The subsequent arguments to the insert method set the configuration options of the individual attributes of the new item.


http://tix.sourceforge.net