Version 28 of notebook

Updated 2004-09-23 15:33:12 by lwv

There are notebook widgets available in a variety of Tcl related

  * There's the [IWidgets] version

http://incrtcl.sourceforge.net/iwidgets/iwidgets/notebook.gif

See docs at http://incrtcl.sourceforge.net/iwidgets/iwidgets/notebook.html and http://purl.org/tcl/home/man/iwidgets3.0/notebook.n.html

See also Notebook App.


Rohan Pall Wow, this page is popular ;) So here's my two cents: I keep examples of each little Tcl/Tk component. This way I don't forget how to do something. Here is my BWidgets NoteBook example. If I remember correctly, I think I learnt this from Bryan Oakley in a comp.lang.tcl newsgroup posting.

BWidgets is an excellent package.

The code has been tested with BWidget 1.4.1 on

  • Windows98 the first release, not second edition
  • a custom version of Linux (means I don't remember what I did to it ;)
  package require BWidget

  set nb [NoteBook .nb -side top]
  $nb insert 0 foo -text "foo"
  $nb insert 1 bar -text "bar"

  set pane [$nb getframe foo]
  label $pane.hello -text "hello world"
  pack $pane.hello -fill both -expand 1

  set pane [$nb getframe bar]
  button $pane.fizz -text testing
  pack $pane.fizz -fill both -expand true

  pack $nb -fill both -expand 1
  $nb raise foo

Michael Jacobson Oct 8, 2002 ~ I was trying to get the BWidgets NoteBook to work with a popup menu displayed on the active tab when you right clicked on the tab. I thought I would document how to do it below.

http://mywebpages.comcast.net/jakeforce/bwidget_notebook.jpg

 package require BWidget

 ## create a notebook with 2 text panes
 NoteBook .n
 .n insert 0 text1 -text Text1
 .n insert 1 text2 -text Text2
 foreach panel {text1 text2} {
        set pane [.n getframe $panel]
        text $pane.t
        pack $pane.t -fill both -expand 1
 }
 pack .n
 .n raise text1

 ## make a popup menu for the tabs (just add commands)
 menu .popup -tearoff 0 -activeborderwidth 0
 .popup add command -label "mess 1" -command [list puts "in mess 1"]
 .popup add command -label "mess 2" -command [list puts "in mess 2"]
 .popup add separator
 .popup add command -label "mess n" -command [list puts "in mess n"] 

 ## bind right mouse button to the popup menus
 .n bindtabs <Button-3> [list popup .popup %X %Y]

 proc popup {win X Y pane} {
        # check to see if current click is on the top tab
        if {[string equal [.n raise] $pane]} {
                tk_popup $win $X $Y
        }
 }

Category Example | Category Widgets | Category Command