1iwidgets::notebook − create and manipulate notebook widgets iwid‐

gets::notebook pathName ?options? itk::Widget <‐ iwidgets::Note‐

3book

background foreground scrollCommand width

cursor height

6See  the  "options"  manual entry for details on the standard op‐
7tions.
8Name:           auto
9Class:          Auto
10Command‐Line Switch:           ‐auto
11Specifies whether to use the  automatic  packing/unpacking  algo‐
12rithm of the notebook. A value of true indicates that page frames
13will be unpacked and packed acoording to the algorithm  described
14in  the select command.  A value of false leaves the current page
15packed and subsequent selects, next, or previous commands do  not
16switch  pages automatically. In either case the page’s associated
17command (see the add command’s description of the command option)
18is  invoked.  The value may have any of the forms accepted by the

Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. For exam‐

20ple,  if  a  series  of pages in a notebook simply change certain
21display configurations of a graphical  display,  the  ‐auto  flag
22could  be  used.   By setting it, the ‐command procs could do the
23appropriate reconfiguring of the page when the page is  switched.
24The iwidgets::notebook command creates a new window (given by the
25pathName argument) and makes it into a notebook widget. Addition‐
26al  options, described above may be specified on the command line
27or in the option database to configure aspects  of  the  notebook
28such  as its colors, font, and text.  The iwidgets::notebook com‐
29mand returns its pathName argument. At the time this  command  is
30invoked,  there must not exist a window named pathName, but path‐
31Name’s parent must exist.
32
33A notebook is a widget that contains a set of pages. It  displays
34one  page  from  the set as the selected page. When a page is se‐
35lected, the page’s contents are displayed in the page area.  When
36first  created  a  notebook  has  no pages. Pages may be added or
37deleted using widget commands described below.
38
39A notebook’s pages area contains a single child site frame.  When
40a  new  page  is  created it is a child of this frame. The page’s
41child site frame serves as a geometry container for  applications
42to  pack widgets into. It is this frame that is automatically un‐
43packed or packed when the auto option is true. This  creates  the
44effect  of  one  page being visible at a time. When a new page is
45selected, the previously selected page’s child site frame is  au‐
46tomatically unpacked from the notebook’s child site frame and the
47newly selected page’s child site is packed  into  the  notebook’s
48child site frame.
49
50However,  sometimes  it  is desirable to handle page changes in a
51different manner. By specifying the auto option as  false,  child
52site  packing  can be disabled and done differently. For example,
53all widgets might be packed into  the  first  page’s  child  site
54frame.  Then when a new page is selected, the application can re‐
55configure the widgets and give the appearance that the  page  was
56flipped.
57
58In  both cases the command option for a page specifies a Tcl Com‐
59mand to execute when the page is selected. In the  case  of  auto
60being  true, it is called between the unpacking of the previously
61selected page and the packing of the newly selected page.
62
63The iwidgets::notebookfR command creates a new Tcl command  whose

name is pathName. This command may be used to invoke various op‐

65erations on the widget. It has the following general form:  path‐

Name option ?arg arg ...? option and the args determine the ex‐

67act behavior of the command.  Many of the widget commands  for  a
68notebook  take  as one argument an indicator of which page of the
69notebook to operate on. These indicators are called  indexes  and
70may  be specified in any of the following forms: number Specifies
71the index of the the component. For menus, 0 corresponds  to  the
72left‐most menu of the menu bar. For entries, 0 corresponds to the
73top‐most entry of the menu.  number Specifies the page numerical‐
74ly,  where  0 corresponds to the first page in the notebook, 1 to
75the second, and so on.  select Specifies the  currently  selected
76page’s  index.  If no page is currently selected, the value ‐1 is
77returned.  end Specifes the last page in the  notebooks’s  index.
78If the notebook is empty this will return ‐1.  pattern If the in‐
79dex doesn’t satisfy the form of a number, then this form is used.
80Pattern  is pattern‐matched against the label of each page in the
81notebook, in order from the first  to  the  last  page,  until  a
82matching  entry  is found. The rules of Tcl_StringMatch are used.
83The following commands are possible for notebook  widgets:  path‐

Name add ?option value? Add a new page at the end of the note‐

85book. A new child site frame is created. Returns the  child  site
86pathName.  If  additional arguments are present, they specify any
87of the following options: ‐background  value  Specifies  a  back‐
88ground  color  to use for displaying the child site frame of this
89page. If this option is specified as an  empty  string  (the  de‐
90fault),  then  the  background option for the overall notebook is
91used.  ‐command value Specifies a Tcl command to be executed when
92this  page  is selected. This allows the programmer a hook to re‐
93configure this page’s widgets or any other  page’s  widgets.   If
94the  notebook has the auto option set to true, when a page is se‐
95lected this command will be called immediately after  the  previ‐
96ously  selected page is unpacked and immediately before this page
97is selected. The index value select is valid during this Tcl com‐
98mand. ‘index select’ will return this page’s page number.  If the
99auto option is set to false, when a page is selected  the  unpack
100and  pack  calls  are bypassed. This Tcl command is still called.

‐foreground value Specifies a foreground color to use for dis‐

102playing  tab  labels  when  tabs  are  in their normal unselected
103state. If this option is specified as an empty  string  (the  de‐
104fault),  then  the  foreground option for the overall notebook is
105used.  ‐label value Specifies a string  to  associate  with  this
106page.  This label serves as an additional identifier used to ref‐
107erence the page. This label may be used for the  index  value  in
108widget  commands.  pathName childSite ?index?  If passed no argu‐
109ments, returns a list of pathNames for all the pages in the note‐
110book.  If the notebook is empty, an empty list is returned If in‐
111dex is passed, it returns the pathName for the page’s child  site
112frame  specified  by  index.  Widgets  that are created with this
113pathName will be displayed when the associated page is  selected.
114If  index  is  not  a  valid  index, an empty string is returned.

pathName cget option Returns the current value of the configura‐

116tion  option given by option.  pathName configure ?option? ?value

option value ...? Query or modify the configuration options of

118the  widget. If no option is specified, returns a list describing
119all of the available options for pathName  (see  Tk_ConfigureInfo
120for  information on the format of this list). If option is speci‐
121fied with no value, then the command returns  a  list  describing
122the  one  named option (this list will be identical to the corre‐
123sponding sublist of the value returned if  no  option  is  speci‐
124fied).  If one or more option‐value pairs are specified, then the
125command modifies the given widget option(s)  to  have  the  given
126value(s);  in  this case the command returns an empty string. Op‐

tion may have any of the values accepted by the iwidgets::note‐

book command. pathName delete index1 ?index2? Delete all of the

129pages between index1 and index2 inclusive.  If index2 is  omitted
130then  it  defaults  to index1. Returns an empty string.  pathName

index index Returns the numerical index corresponding to index.

pathName insert index ?option value? Insert a new page in the

133notebook before the page specified by index.  A  new  child  site

frame is created. See the add command for valid options. Returns

135the child site pathName.  pathName  next  Advances  the  selected
136page  to  the next page (order is determined by insertion order).
137If the currently selected page is the last page in the  notebook,
138the  selection  wraps  around  to the first page in the notebook.
139For notebooks with auto set to true the current page’s child site
140is  unpacked  from the notebook’s child site frame. Then the next
141page’s child site is packed into the notebooks child site  frame.
142The Tcl command given with the command option will be invoked be‐
143tween these two operations.  For notebooks with auto set to false
144the  Tcl  command  given with the command option will be invoked.

pathName pagecget index ?option? Returns the current value of

146the  configuration  option given by option for the page specified
147by index. The valid available options are the same  as  available
148to the add command.  pathName pageconfigure index ?option? ?value

option value ...? This command is similar to the configure com‐

150mand,  except  that  it  applies to the options for an individual
151page, whereas configure applies to the options for the  notebook.
152Options  may  have  any  of the values accepted by the add widget
153command. If options are specified, options are modified as  indi‐
154cated  in the command and the command returns an empty string. If
155no options are specified, returns a list describing  the  current
156options  for  page index (see Tk_ConfigureInfo for information on
157the format of this list).  pathName prev Moves the selected  page
158to the previous page (order is determined by insertion order). If
159the currently selected page is the first page  in  the  notebook,
160the selection wraps around to the last page in the notebook.  For
161notebooks with auto set to true the current page’s child site  is
162unpacked  from the notebook’s child site frame. Then the previous
163page’s child site is packed into the notebooks child site  frame.
164The Tcl command given with the command option will be invoked be‐
165tween these two operations.  For notebooks with auto set to false
166the  Tcl  command  given with the command option will be invoked.

pathName select index Selects the page specified by index as the

168currently selected page.  For notebooks with auto set to true the
169current page’s child site is unpacked from the  notebook’s  child
170site  frame.  Then the index page’s child site is packed into the
171notebooks child site frame. The Tcl command given with  the  com‐
172mand  option  will  be invoked between these two operations.  For
173notebooks with auto set to false the Tcl command given  with  the
174command  option  will be invoked.  pathName view Returns the cur‐
175rently selected page. This command is for compatibility with  the
176scrollbar widget.  pathName view index Selects the page specified
177by index as the currently selected page.   This  command  is  for
178compatibility  with  the  scrollbar widget.  pathName view moveto

fraction Uses the fraction value to determine the corresponding

180page  to  move  to.   This  command is for compatibility with the
181scrollbar widget.  pathName view scroll num  what  Uses  the  num
182value  to  determine  how  many pages to move forward or backward
183(num can be negative or positive). The what argument is  ignored.
184This command is for compatibility with the scrollbar widget.
185
186Following  is  an example that creates a notebook with two pages.
187In this example, we use a scrollbar widget to control  the  note‐
188book widget.
189package require Iwidgets 4.0
190# Create the notebook widget and pack it.
191  iwidgets::notebook .nb ‐width 100 ‐height 100
192  pack .nb ‐anchor nw \
193        ‐fill both \
194        ‐expand yes \
195        ‐side left \
196        ‐padx 10 \
197        ‐pady 10
198# Add two pages to the notebook, labelled
199# "Page One" and "Page Two", respectively.
200  .nb add ‐label "Page One"
201  .nb add ‐label "Page Two"
202# Get the child site frames of these two pages.
203  set page1CS [.nb childsite 0]
204  set page2CS [.nb childsite "Page Two"]
205# Create buttons on each page of the notebook
206  button $page1CS.b ‐text "Button One"
207  pack $page1CS.b
208  button $page2CS.b ‐text "Button Two"
209  pack $page2CS.b
210# Select the first page of the notebook
211  .nb select 0
212# Create the scrollbar and associate teh scrollbar
213# and the notebook together, then pack the scrollbar
214  scrollbar .scroll ‐command ".nb view"
215  .nb configure ‐scrollcommand ".scroll set"
216  pack .scroll ‐fill y ‐expand yes ‐pady 10
217Bill W. Scott notebook page
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Impressum