Artifact
8d950a29a6eb673011cdeddf164f57b45acf65520c36e536f81ec9fb77e89f51:
Attachment "nbtest.tcl" to
ticket [01153381]
added by
nemethi
2026-04-09 09:47:44.
#! /usr/bin/env tclsh
package require Tk
package require opt
font create BigFont {*}[font configure TkDefaultFont] -size 30
ttk::frame .f
#
# tk::menubutton for switching the theme
# --------------------------------------
#
ttk::menubutton .mb -menu .mb.m
menu .mb.m -tearoff 0
### set themeList [ttk::style theme names] ;# built-in themes only
set themeList [ttk::themes] ;# third-party themes, too
foreach theme [lsort $themeList] {
.mb.m add command -label $theme -command [list setTheme $theme]
}
proc setTheme theme {
ttk::setTheme $theme
.mb configure -text $theme
set bg [ttk::style lookup . -background]
set fg [ttk::style lookup . -foreground {} black]
.mb.m configure -background $bg -foreground $fg
foreach opt {-activebackground -activeborderwidth -activeforeground
-borderwidth -relief} {
set defaultVal [lindex [.mb.m configure $opt] 3]
.mb.m configure $opt $defaultVal
}
ttk::style configure TLabel -background white -foreground black \
-font BigFont -padding 15p
ttk::style configure NW.TNotebook -tabposition nw ;# -tabplacement ws
# ttk::configureNotebookStyle NW.TNotebook
ttk::style configure SE.TNotebook -tabposition se -tabplacement en
ttk::configureNotebookStyle SE.TNotebook
ttk::style configure WN.TNotebook -tabposition wn ;# -tabplacement ne
ttk::configureNotebookStyle WN.TNotebook
ttk::style configure ES.TNotebook -tabposition es -tabplacement sw
ttk::configureNotebookStyle ES.TNotebook
}
set origTheme [expr {$argc == 0 ? [ttk::style theme use] : [lindex $argv 0]}]
setTheme $origTheme
#
# Tab position nw (default)
# -------------------------
#
ttk::notebook .nbNW -style NW.TNotebook
ttk::label .l0NW -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1NW -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2NW -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbNW add .l0NW -text "Tab 0" -padding 9p
.nbNW add .l1NW -text "Tab 1" -padding 9p
.nbNW add .l2NW -text "Tab 2" -padding 9p
#
# Tab position se
# ---------------
#
ttk::notebook .nbSE -style SE.TNotebook
ttk::label .l0SE -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1SE -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2SE -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbSE add .l0SE -text "Tab 0" -padding 9p
.nbSE add .l1SE -text "Tab 1" -padding 9p
.nbSE add .l2SE -text "Tab 2" -padding 9p
#
# Tab position wn
# ---------------
#
ttk::notebook .nbWN -style WN.TNotebook
ttk::label .l0WN -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1WN -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2WN -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbWN add .l0WN -text "Tab 0" -padding 9p
.nbWN add .l1WN -text "Tab 1" -padding 9p
.nbWN add .l2WN -text "Tab 2" -padding 9p
#
# Tab position es
# ---------------
#
ttk::notebook .nbES -style ES.TNotebook
ttk::label .l0ES -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1ES -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2ES -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbES add .l0ES -text "Tab 0" -padding 9p
.nbES add .l1ES -text "Tab 1" -padding 9p
.nbES add .l2ES -text "Tab 2" -padding 9p
ttk::button .b -text "Close" -command exit
grid .nbNW .nbWN -in .f -padx 9p -pady 9p -sticky news
grid .nbSE .nbES -in .f -padx 9p -pady 9p -sticky news
grid .mb .b -in .f -padx 9p -pady 9p
grid configure .mb -sticky w
grid configure .b -sticky e
grid rowconfigure .f 0 -weight 1
grid rowconfigure .f 1 -weight 1
grid columnconfigure .f 0 -weight 1
grid columnconfigure .f 1 -weight 1
pack .f -expand yes -fill both