iwidgets::notebook(1)

πŸ’– iwidgets::notebook β€” the manual page, but make it make sense πŸ’–

okay bestie, sit down, we're learning about iwidgets::notebook from the [incr Widgets] collection, and honestly? it's giving organized tabs energy. slay. ✨


🌸 NAME 🌸

iwidgets::notebook β€” create and manipulate notebook widgets


πŸŽ€ SYNOPSIS πŸŽ€

iwidgets::notebook pathName ?options?

πŸ¦‹ INHERITANCE πŸ¦‹

itk::Widget <- iwidgets::Notebook

(so it inherits all the itk::Widget stuff first, then Notebook does its own thing on top πŸ’…)


⭐ STANDARD OPTIONS ⭐

  • background
  • foreground
  • scrollCommand
  • width
  • cursor
  • height

fr fr, these are the classics. for the full tea on what each one does, go read the "options" manual entry. iykyk. πŸ’œ


✨ WIDGET-SPECIFIC OPTIONS ✨

  • Name: auto
  • Class: Auto
  • Command-Line Switch: -auto

so here's the deal with -auto, bestie: it says whether the notebook uses its automatic packing/unpacking algorithm. πŸ‘‘

if it's true, that means page frames get unpacked and packed according to the algorithm described over in the select command. if it's false, the current page just stays packed, and any later select, next, or previous commands will not switch pages automatically. either way β€” true or false β€” the page's associated command still gets invoked (peep the add command's description of the command option for that one). and the value can be literally any of the forms Tcl_GetBoolean accepts, like true, false, 0, 1, yes, or no. no cap. 🌈

for example, imagine you've got a series of pages in a notebook that just change certain display configurations of a graphical display β€” that's literally the moment for the -auto flag. set it, and the -command procs can do the appropriate reconfiguring of the page whenever the page gets switched. iconic behavior honestly. πŸ’…


🌟 DESCRIPTION 🌟

the iwidgets::notebook command creates a brand new window β€” the one you name with the pathName argument β€” and makes it into a notebook widget. 🫢

you can pass extra options (the ones described above) on the command line, or stick them in the option database, to configure aspects of the notebook like its colors, font, and text. and iwidgets::notebook returns its pathName argument, like a good little command. 😌

heads up: when you invoke this command, there must not already be a window named pathName. but pathName's parent must exist. them's the rules.

so what even is a notebook? it's a widget that holds a set of pages, and it displays one page from that set as the selected page. when a page is selected, that page's contents show up in the page area. πŸ“

when a notebook is first created, it has no pages. zero. none. you add or delete pages using the widget commands described below. (soon, bestie, we'll get to those.)


🧚 NOTEBOOK PAGES 🧚

a notebook's pages area contains a single child site frame. when a new page gets created, it becomes a child of that frame. that page's child site frame is basically the geometry container where applications pack their widgets into. πŸ“¦

and it's this frame that gets automatically unpacked or packed when the auto option is true β€” which creates that whole "only one page is visible at a time" effect. when a new page is selected, the previously selected page's child site frame gets automatically unpacked from the notebook's child site frame, and the newly selected page's child site gets packed into the notebook's child site frame. boom, page flip. πŸ”₯

but sometimes you wanna handle page changes differently, and that's valid! by specifying the auto option as false, child site packing gets disabled and you can do it your own way. for example, all the widgets might be packed into the first page's child site frame. then when a new page is selected, the application can reconfigure the widgets and give the appearance that the page was flipped. sneaky. love that for you. πŸ’€

in both cases, the command option for a page specifies a Tcl Command to execute when the page is selected. and when auto is true, that command gets called between the unpacking of the previously selected page and the packing of the newly selected page. timing is everything, bestie. ⏱️✨

✨ WIDGET-SPECIFIC METHODS ✨

The iwidgets::notebook command creates a new Tcl command whose name is pathName. Bestie, this command is literally the remote control for your widget β€” you use it to invoke various operations on it. General form goes like this:

pathName option ?arg arg ...?

The option and the args decide what the command actually does. No cap.

A bunch of these widget commands need you to say which page of the notebook you're talking about. Those indicators are called indexes, and you can hand them over in any of these forms:

  • number β€” Specifies the index of the the component. For menus, 0 corresponds to the left-most menu of the menu bar. For entries, 0 corresponds to the top-most entry of the menu. πŸ’€ (yes that's in here, we don't ask questions, we just report it)
  • number β€” Specifies the page numerically, where 0 corresponds to the first page in the notebook, 1 to the second, and so on. zero-indexed girlies rise ✨
  • select β€” Specifies the currently selected page's index. If no page is currently selected, the value -1 is returned. not me checking if anything's even selected…
  • end β€” Specifes the last page in the notebooks's index. If the notebook is empty this will return -1.
  • pattern β€” If the index doesn't satisfy the form of a number, then this form is used. Pattern is pattern-matched against the label of each page in the notebook, in order from the first to the last page, until a matching entry is found. The rules of Tcl_StringMatch are used. fuzzy matching bestie, it's giving ✨vibes✨

............................................................

Okay so now the actual commands, the main characters of this whole page: πŸ‘‘
  • pathName add ?option value? β€” Add a new page at the end of the notebook. A new child site frame is created. Returns the child site pathName. If additional arguments are present, they specify any of the following options:
    • -background value β€” Specifies a background color to use for displaying the child site frame of this page. If this option is specified as an empty string (the default), then the background option for the overall notebook is used. πŸŽ€
    • -command value β€” Specifies a Tcl command to be executed when this page is selected. This allows the programmer a hook to reconfigure this page's widgets or any other page's widgets.

If the notebook has the auto option set to true, when a page is selected this command will be called immediately after the previously selected page is unpacked and immediately before this page is selected. The index value select is valid during this Tcl command. index select will return this page's page number.

If the auto option is set to false, when a page is selected the unpack and pack calls are bypassed. This Tcl command is still called.

  • -foreground value β€” Specifies a foreground color to use for displaying tab labels when tabs are in their normal unselected state. If this option is specified as an empty string (the default), then the foreground option for the overall notebook is used. πŸ’…
  • -label value β€” Specifies a string to associate with this page. This label serves as an additional identifier used to reference the page. This label may be used for the index value in widget commands. name your pages, they deserve it
  • pathName childSite ?index? β€” If passed no arguments, returns a list of *pathName*s for all the pages in the notebook. If the notebook is empty, an empty list is returned.

If index is passed, it returns the pathName for the page's child site frame specified by index. Widgets that are created with this pathName will be displayed when the associated page is selected. If index is not a valid index, an empty string is returned. 🫢

  • pathName cget option β€” Returns the current value of the configuration option given by option.
  • pathName configure ?option? ?value option value ...? β€” Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the iwidgets::notebook command. one stop shop, we love to see it
  • pathName delete index1 ?index2? β€” Delete all of the pages between index1 and index2 inclusive. If index2 is omitted then it defaults to index1. Returns an empty string. goodbye bestie, inclusive on both ends 😭
  • pathName index index β€” Returns the numerical index corresponding to index. πŸ”’
  • pathName insert index ?option value? β€” Insert a new page in the notebook before the page specified by index. A new child site frame is created. See the add command for valid options. Returns the child site pathName.
  • pathName next β€” Advances the selected page to the next page (order is determined by insertion order). If the currently selected page is the last page in the notebook, the selection wraps around to the first page in the notebook. it's giving carousel energy 🎠

For notebooks with auto set to true the current page's child site is unpacked from the notebook's child site frame. Then the next page's child site is packed into the notebooks child site frame. The Tcl command given with the command option will be invoked between these two operations.

For notebooks with auto set to false the Tcl command given with the command option will be invoked.

  • pathName pagecget index ?option? β€” Returns the current value of the configuration option given by option for the page specified by index. The valid available options are the same as available to the add command.
  • pathName pageconfigure index ?option? ?value option value ...? β€” This command is similar to the configure command, except that it applies to the options for an individual page, whereas configure applies to the options for the notebook. Options may have any of the values accepted by the add widget command. If options are specified, options are modified as indicated in the command and the command returns an empty string. If no options are specified, returns a list describing the current options for page index (see Tk_ConfigureInfo for information on the format of this list). 🧚
  • pathName prev β€” Moves the selected page to the previous page (order is determined by insertion order). If the currently selected page is the first page in the notebook, the selection wraps around to the last page in the notebook.

For notebooks with auto set to true the current page's child site is unpacked from the notebook's child site frame. Then the previous page's child site is packed into the notebooks child site frame. The Tcl command given with the command option will be invoked between these two operations.

For notebooks with auto set to false the Tcl command given with the command option will be invoked.

  • pathName select index β€” Selects the page specified by index as the currently selected page. main character page selection moment πŸ‘‘

For notebooks with auto set to true the current page's child site is unpacked from the notebook's child site frame. Then the index page's child site is packed into the notebooks child site frame. The Tcl command given with the command option will be invoked between these two operations.

For notebooks with auto set to false the Tcl command given with the command option will be invoked.

  • pathName view β€” Returns the currently selected page. This command is for compatibility with the scrollbar widget. 🎚️
  • pathName view index β€” Selects the page specified by index as the currently selected page. This command is for compatibility with the scrollbar widget.
  • pathName view moveto fraction β€” Uses the fraction value to determine the corresponding page to move to. This command is for compatibility with the scrollbar widget.
  • pathName view scroll num what β€” Uses the num value to determine how many pages to move forward or backward (num can be negative or positive). The what argument is ignored. This command is for compatibility with the scrollbar widget. what? ignored. we move regardless πŸ’œ

🌸 EXAMPLE 🌸

Following is an example that creates a notebook with two pages. In this example, we use a scrollbar widget to control the notebook widget. copy-paste girlies, this one's for you πŸ“

package require Iwidgets 4.0
# Create the notebook widget and pack it.
  iwidgets::notebook .nb -width 100 -height 100
  pack .nb -anchor nw \
        -fill both \
        -expand yes \
        -side left \
        -padx 10 \
        -pady 10

# Add two pages to the notebook, labelled
# "Page One" and "Page Two", respectively.
  .nb add -label "Page One"
  .nb add -label "Page Two"

# Get the child site frames of these two pages.
  set page1CS [.nb childsite 0]
  set page2CS [.nb childsite "Page Two"]

# Create buttons on each page of the notebook
  button $page1CS.b -text "Button One"
  pack $page1CS.b
  button $page2CS.b -text "Button Two"
  pack $page2CS.b

# Select the first page of the notebook
  .nb select 0

# Create the scrollbar and associate teh scrollbar
# and the notebook together, then pack the scrollbar
  scrollbar .scroll -command ".nb view"
  .nb configure -scrollcommand ".scroll set"
  pack .scroll -fill y -expand yes -pady 10
Note the comment says "teh" β€” that's not me, that's verbatim from the original. We preserve. Periodt. πŸ’…

πŸ¦‹ AUTHOR πŸ¦‹

Bill W. Scott legend behaviour, honestly


πŸ’– KEYWORDS πŸ’–

notebook page


Okay that's the whole page bestie, you made it to the end and you ate πŸŽ€βœ¨ This one comes from the Tk source, and the manual page is iwidgets::notebook(1) β€” go forth and stack those pages, you've got this πŸ’œπŸ«ΆπŸŒΈ

πŸ“¦ where this page comes from