Version 2 of ScrolledWindow

Updated 2003-09-25 12:01:59

Purpose: http://tcllib.sourceforge.net/BWman/ScrolledWindow.html is the documentation for BWidget's ScrolledWindow. Hopefully people will provide examples of using this widget.

Some examples of using BWidget's ScrolledWindow. First, make a frame scrollable:

 package require BWidget

 # Make a frame scrollable

 set sw [ScrolledWindow .sw]
 pack $sw -fill both -expand true

 set sf [ScrollableFrame $sw.sf]

 $sw setwidget $sf

 set uf [$sf getframe]

 # Now fill the frame, resize the window to see the scrollbars in action

 for { set i 0 } { $i < 20 } { incr i } { 
     for { set j 0 } { $j < 20 } { incr j } { 
          set nm [format "%s.b_%s_%s" $uf $i $j]
          set b [button $nm -text "$i,$j"]
         grid $b -row $i -column $j
     }
 }

A text widget can be make scrollable like this:

 package require BWidget

 # Make a text-widget scrollable

 set sw [ScrolledWindow .sw]
 pack $sw -fill both -expand true

 set txt [text $sw.txt -wrap none]

 $sw setwidget $txt

 # Insert some text, resize the window to see the scrollbars in action

 $txt insert end {README:  Tcl
    This is the Tcl 8.4.3 source distribution.
    Tcl/Tk is also available through NetCVS:
        http://tcl.sourceforge.net/
    You can get any source release of Tcl from the file distributions
    link at the above URL.

 RCS: @(#) $Id: 9924,v 1.3 2003-09-26 08:00:38 jcw Exp $

 Contents
 --------
  1. Introduction
  2. Documentation
  3. Compiling and installing Tcl
  4. Development tools
  5. Tcl newsgroup
  6. Tcl contributed archive
  7. Tcl Resource Center
  8. Mailing lists
  9. Support and Training
    1. Thank You
 }

Listboxes (standard Tk of BWidget) can be make scrollable like this:

 package require BWidget

 # Make a tk-listbox scrollable

 set swtk [ScrolledWindow .swtk]
 pack $swtk -fill both -expand true

 set lbtk [listbox $swtk.lbtk]

 $swtk setwidget $lbtk

 # Make a BWidget-listbox scrollable

 set swbw [ScrolledWindow .swbw]
 pack $swbw -fill both -expand true

 set lbbw [ListBox $swbw.lbbw]

 $swbw setwidget $lbbw

 # Now fill the listbox, resize the window to see the scrollbars in action

 for { set i 0 } { $i < 100 } { incr i } {
     $lbtk insert end "This is item $i"
     $lbbw insert $i $i -text "This is item $i"
 }
















Category Command , a part of Bwidget | Category GUI