| 1 |
#!../src/bltwish |
| 2 |
|
| 3 |
package require BLT |
| 4 |
# -------------------------------------------------------------------------- |
| 5 |
# Starting with Tcl 8.x, the BLT commands are stored in their own |
| 6 |
# namespace called "blt". The idea is to prevent name clashes with |
| 7 |
# Tcl commands and variables from other packages, such as a "table" |
| 8 |
# command in two different packages. |
| 9 |
# |
| 10 |
# You can access the BLT commands in a couple of ways. You can prefix |
| 11 |
# all the BLT commands with the namespace qualifier "blt::" |
| 12 |
# |
| 13 |
# blt::graph .g |
| 14 |
# blt::table . .g -resize both |
| 15 |
# |
| 16 |
# or you can import all the command into the global namespace. |
| 17 |
# |
| 18 |
# namespace import blt::* |
| 19 |
# graph .g |
| 20 |
# table . .g -resize both |
| 21 |
# |
| 22 |
# -------------------------------------------------------------------------- |
| 23 |
if { $tcl_version >= 8.0 } { |
| 24 |
namespace import blt::* |
| 25 |
namespace import -force blt::tile::* |
| 26 |
} |
| 27 |
source scripts/demo.tcl |
| 28 |
|
| 29 |
# Create a tabnotebook widget. |
| 30 |
|
| 31 |
tabnotebook .tnb |
| 32 |
|
| 33 |
# The notebook is initially empty. Insert tabs (pages) into the notebook. |
| 34 |
|
| 35 |
foreach label { First Second Third Fourth } { |
| 36 |
.tnb insert end -text $label |
| 37 |
} |
| 38 |
|
| 39 |
# Tabs are referred to by their index. Tab indices can be one of the |
| 40 |
# following: |
| 41 |
# |
| 42 |
# number Position of tab the notebook's list of tabs. |
| 43 |
# @x,y Tab closest to the specified X-Y screen coordinates. |
| 44 |
# "active" Tab currently under the mouse pointer. |
| 45 |
# "focus" Tab that has focus. |
| 46 |
# "select" The currently selected tab. |
| 47 |
# "right" Next tab from "focus". |
| 48 |
# "left" Previous tab from "focus". |
| 49 |
# "up" Next tab from "focus". |
| 50 |
# "down" Previous tab from "focus". |
| 51 |
# "end" Last tab in list. |
| 52 |
# string Tab identifier. The "insert" operation returns |
| 53 |
# a unique identifier for the new tab (e.g. "tab0"). |
| 54 |
# This ID is valid for the life of the tab, even if |
| 55 |
# the tabs are moved or reordered. |
| 56 |
|
| 57 |
# Each tab has a text label and an optional Tk image. |
| 58 |
|
| 59 |
set image [image create photo -file ./images/mini-book1.gif] |
| 60 |
.tnb tab configure 0 -image $image |
| 61 |
|
| 62 |
# |
| 63 |
# How to embed a widget into a page. |
| 64 |
# |
| 65 |
|
| 66 |
# 1. The widget must be a child of the tabnotebook. |
| 67 |
|
| 68 |
set image [image create photo -file ./images/blt98.gif] |
| 69 |
label .tnb.label -image $image -relief sunken -bd 2 |
| 70 |
|
| 71 |
# 2. Use the -window option to embed the widget. |
| 72 |
|
| 73 |
.tnb tab configure 0 -window .tnb.label |
| 74 |
|
| 75 |
# The tearoff perforation, displayed on the selected tab, is |
| 76 |
# controlled by the tabnotebook's -tearoff option. |
| 77 |
# |
| 78 |
# If you don't want tearoff pages, configure -tearoff to "no". |
| 79 |
|
| 80 |
.tnb configure -tearoff yes |
| 81 |
|
| 82 |
table . \ |
| 83 |
0,0 .tnb -fill both |
| 84 |
|
| 85 |
focus .tnb |
| 86 |
|