TCL Utility Scripts

Tag: REFERENCE
Edit
A little window for creating text pasting buttons.
#! /bin/env wish

wm title . "Paste Kit"
wm minsize . 300 200
wm attributes . -topmost true

set numPastes 1

proc addPaste {text} {
        global numPastes
        set btnName .pastebtn$numPastes
        ::ttk::button $btnName -text $text -command "
        clipboard clear
        clipboard append {$text}"
        ::ttk::button ${btnName}Rm -text "Remove" -command "destroy $btnName ${btnName}Rm ${btnName}lbl ${btnName}divider"
        ::ttk::label ${btnName}lbl -text "[.description get]"
        ::ttk::label ${btnName}divider -text "|"
        grid ${btnName}lbl ${btnName}divider $btnName ${btnName}Rm  -row [expr $numPastes + 1]
        set numPastes [expr 1 + $numPastes]
}

::ttk::button .add -text "Add Paste" -command {
        addPaste [.text get]
}
::ttk::entry .description
::ttk::entry .text
::ttk::label .divider -text "|"

grid .description .divider .text .add