Version 2 of xtk::notebook

Updated 2016-05-30 16:34:50 by MG

JayBy 2016-05-30

xtk::notebook extends the ttk::notebook with buttons for scrolling, add and remove tabs.

xtk::notebook-Image-1

Download

Version 0.1
xtk_notebook-0.1.zip

Usage

package require xtk::notebook ?0.1?

COMMANDS

xtk::notebook <Path> ?options?
Create the new notebook and returns the pathname.
xtk::notebook::addTab <Nb> ?options?
Builtin command for creating a new tab in given notebook. It returns the pathname of the new frame inside the added tab.

NOTEBOOK OPTIONS

Default options from ttk::notebook and new added options:

-addbutton <Bool>
If 'string is true <Bool>', it creates add and close buttons, and also buttons for scrolling.
Default: false
-scrollbuttons <Bool>
If 'string is true <Bool>', it creates the scroll buttons for the tabs.
Default: false
-addcommand <Script>
<Script> is used in place of the builtin command to create a new tab.
Default: builtin command

TAB OPTIONS

Options for the builtin addTab command:

-text <String>
Set title of the new tab.
Default: "Tab <Nr>"
-win <Win>
Define a window, which will be inserted, instead of a new frame. This will be returned by the addTab command.
-index c | current | a | b | e | end | <Number>
Insert tab at specified position:
c|current -> after the current tab
a -> after the current tab
b -> before the current tab
e|end -> at the end
<Number> -> position of the specified number

MG just tried this out on Windows 7, out of curiosity, and ran into a few problems:

  • The "+" button doesn't work, and gives an error:
can't read "_W": no such variable
can't read "_W": no such variable
    while executing
"::xtk::notebook::addTab $_W"
    invoked from within
".nb.addButton invoke "
    invoked from within
".nb.addButton instate !disabled { .nb.addButton invoke } "
    invoked from within
".nb.addButton instate pressed { .nb.addButton state !pressed; .nb.addButton instate !disabled { .nb.addButton invoke } } "
    (command bound to event)
  • Before I got that error from the "+" button, addTab worked fine. Afterwards, though, addTab returned an error: can't read "Nb(.nb,Last)": no such element in array. (The new tab was still added, though.)
  • The scroll buttons are permanantly disabled; I added a bunch of new tabs with really long names, and it just caused tab sizes to shrink. But even when I resized the toplevel so that some tabs were forced out of view, the scroll buttons still remained disabled.