Whenever you give a command, such as button ...
, the Tcl interpreter attempts to substitute things like variables and commands as far as possible. This means that if (like in this case) you create a button and set its command with this invocation
button .top.btn -command [destroy .top]
Tcl executes the command destroy .top
as part of executing your button
invocation (and inserts the result value of the execution as a command string passed to the command option). You don't want that to happen (usually, and certainly not in this case, as it saws off the branch your GUI is sitting on), so you need to prevent Tcl from substituting this particular part of the invocation.
If you don't need to substitute anything in the command string that you pass to the command option, you can write it like this
button .top.btn -command {destroy .top}
or (a little more fragile)
button .top.btn -command \[destroy .top]
but in some cases you need to substitute some part of the command string without executing the command. This won't work:
set w .top
button $w.btn -command {destroy $w}
since that would have the button try to execute the unsubstituted command string destroy $w
.
In such cases, it's usually sufficient to wrap the command string in list
:
set w .top
button $w.btn -command [list destroy $w]
So, instead of
button .topbox.btn_1 \
-text "Destroy" \
-width 150 \
-background green \
-command [destroy .topbox]
you should write
button .topbox.btn_1 \
-text "Destroy" \
-width 150 \
-background green \
-command [list destroy .topbox]
or possibly give the command option as
-command {destroy .topbox}
since you don't need to substitute anything.