[CJB]: An example of how to make drag and drop tabs with a ttk::notebook. ---- ====== #Create notebook set n [ttk::notebook .nb] pack $n -fill both -expand 1 #Create tabs foreach tab [list First Second Third] { set w [frame $n.[string tolower $tab]] $n add $w -text $tab bindtags $w [linsert [bindtags $w] 1 DropTarget] } #Bindings bind all {console show} bind $n [list click %W %x %y] bind $n [list release %W %x %y] bind $n [list motion %W %X %Y] #Sets index of tab clicked. proc click {W x y} { variable tab_index [$W index @$x,$y] puts stderr "click $tab_index" } #Moves the tab to the position where it was dropped. proc release {W x y} { variable tab_index puts stderr "Release $tab_index" #Check for a valid source if {[string is int -strict $tab_index]} { set idx [$W index @$x,$y] #Check for a valid destination if {[string is int -strict $idx]} { set tab [lindex [$W tabs] $tab_index] $W insert $idx $tab puts stderr "insert $idx $tab" } } } #Passes mouse motion events to underlying widgets while dragging. #Allows the notebook tabs to highlight on mouse-over. proc motion {W X Y} { set w [winfo containing $X $Y] if {$w ne $W && $w ne ""} { set x [expr {$X - [winfo rootx $w]}] set y [expr {$Y - [winfo rooty $w]}] event generate $w -x $x -y $y } } ====== <>Example|GUI|Widget