Next: Keyboard Accelerators Up: TixNoteBook Previous: TixNoteBook


Adding Pages to a TixNoteBook 

The example program in figure 2-2 creates the TixNoteBook widget shown in figure 2-1. In the first three lines, we create the notebook widget and two pages inside it. While we create the pages, we also set the labels on the tabs associated with each page and use the -underline option to indicate the keyboard accelerator for each page.

Each time we create a page in the notebook using the add method, a frame subwidget is created for us automatically. This frame subwidget has the same name as the page (the first parameter passed to the add method). We can use the subwidget method to find out the pathname of this frame subwidget and pack everything we want to display on the page into this frame widget. Lines 4-10 of program 2-2 shows how to create the widgets inside the ``Hard Disk'' page. Creating the widgets inside the ``Network'' page will be similar.

tixNoteBook .n
.n add hd -label "Hard Disk" -underline 0
.n add net -label "Network" -underline 0

set frame [.n subwidget hd]
tixControl $frame.access -label "Access Time:"
tixControl $frame.write -label "Write Throughput:"
tixControl $ -label "Read Througput:"
tixControl $frame.capacity -label "Capacity:"
pack $frame.access $frame.write $ $frame.capacity
-side top -fill x

(Figure 2-2) Using The TixNoteBook Widget