Artifact
5ed51043613d71fb1173f3852dd64ff41a96e3610437a58701a153039d5debf3:
Attachment "nbtest.tcl" to
ticket [01153381]
added by
nemethi
2026-04-08 14:36:38.
#! /usr/bin/env tclsh
package require Tk
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]
foreach theme [lsort $themeList] {
.mb.m add command -label $theme -command [list setTheme $theme]
}
proc setTheme theme {
ttk::setTheme $theme
.mb configure -text $theme
.mb.m configure -background [ttk::style lookup . -background]
ttk::style configure TLabel -font BigFont -background white -padding 15p
ttk::style configure NW.TNotebook -tabposition nw ;# -tabplacement ws
# ttk::configureNotebookStyle NW.TNotebook
ttk::style configure SW.TNotebook -tabposition se -tabplacement en
ttk::configureNotebookStyle SW.TNotebook
ttk::style configure WN.TNotebook -tabposition wn ;# -tabplacement ne
ttk::configureNotebookStyle WN.TNotebook
ttk::style configure EN.TNotebook -tabposition es -tabplacement sw
ttk::configureNotebookStyle EN.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 sw
# ---------------
#
ttk::notebook .nbSW -style SW.TNotebook
ttk::label .l0SW -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1SW -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2SW -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbSW add .l0SW -text "Tab 0" -padding 9p
.nbSW add .l1SW -text "Tab 1" -padding 9p
.nbSW add .l2SW -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 en
# ---------------
#
ttk::notebook .nbEN -style EN.TNotebook
ttk::label .l0EN -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1EN -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2EN -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbEN add .l0EN -text "Tab 0" -padding 9p
.nbEN add .l1EN -text "Tab 1" -padding 9p
.nbEN add .l2EN -text "Tab 2" -padding 9p
ttk::button .b -text "Close" -command exit
grid .nbNW .nbWN -in .f -padx 9p -pady 9p -sticky news
grid .nbSW .nbEN -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