Tk Source Code

Artifact [3b9ebefe]
Login

Artifact 3b9ebefe86e298e6faf98593ea4059b5690e5e16671db8b24bac857402e132f4:

Attachment "nbtest8.tcl" to ticket [01153381] added by chw 2026-04-10 18:20:40.
#! /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]
#set themeList [ttk::themes]
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

    ## flipped

    ttk::style configure FNW.TNotebook -tabposition ne -tabplacement es
    ttk::configureNotebookStyle FNW.TNotebook

    ttk::style configure FSW.TNotebook -tabposition sw -tabplacement wn
    ttk::configureNotebookStyle FSW.TNotebook

    ttk::style configure FWN.TNotebook -tabposition ws -tabplacement se
    ttk::configureNotebookStyle FWN.TNotebook

    ttk::style configure FEN.TNotebook -tabposition en -tabplacement nw
    ttk::configureNotebookStyle FEN.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

#
# Tab position nw flipped
# -------------------------
#
ttk::notebook .nbFNW -style FNW.TNotebook
ttk::label .l0FNW -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1FNW -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2FNW -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbFNW add .l0FNW -text "Tab 0" -padding 9p
.nbFNW add .l1FNW -text "Tab 1" -padding 9p
.nbFNW add .l2FNW -text "Tab 2" -padding 9p

#
# Tab position sw flipped
# -----------------------
#
ttk::notebook .nbFSW -style FSW.TNotebook
ttk::label .l0FSW -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1FSW -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2FSW -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbFSW add .l0FSW -text "Tab 0" -padding 9p
.nbFSW add .l1FSW -text "Tab 1" -padding 9p
.nbFSW add .l2FSW -text "Tab 2" -padding 9p

#
# Tab position wn flipped
# -----------------------
#
ttk::notebook .nbFWN -style FWN.TNotebook
ttk::label .l0FWN -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1FWN -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2FWN -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbFWN add .l0FWN -text "Tab 0" -padding 9p
.nbFWN add .l1FWN -text "Tab 1" -padding 9p
.nbFWN add .l2FWN -text "Tab 2" -padding 9p

#
# Tab position en flipped
# -----------------------
#
ttk::notebook .nbFEN -style FEN.TNotebook
ttk::label .l0FEN -text "Pane 0" -anchor center -borderwidth 2 -relief groove
ttk::label .l1FEN -text "Pane 1" -anchor center -borderwidth 2 -relief groove
ttk::label .l2FEN -text "Pane 2" -anchor center -borderwidth 2 -relief groove
.nbFEN add .l0FEN -text "Tab 0" -padding 9p
.nbFEN add .l1FEN -text "Tab 1" -padding 9p
.nbFEN add .l2FEN -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 .nbFNW .nbFWN -in .f -padx 9p -pady 9p -sticky news
grid .nbFSW .nbFEN -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 rowconfigure    .f 2 -weight 1
grid rowconfigure    .f 3 -weight 1
grid columnconfigure .f 0 -weight 1
grid columnconfigure .f 1 -weight 1
pack .f -expand yes -fill both