global D if ![info exists D] {set D 1} # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # This little routine creates a debug-level widget and packs it in w # # to the right. We depend on there being a global debug variable D, # # which we will create if it doesn't exist already. The args, if any, # # are included in the menubutton option list, so the caller can do # # things like specify border, relief, font, colors, etc. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc Dbg {w args} { global D F R if ![info exists D] {set D 1} if ![info exists F] {set F 3} if ![info exists R] {set R ridge} eval frame $w.fDbg -bd $F -relief $R eval menubutton $w.fDbg.m $args -text Dbg -menu $w.fDbg.m.menu eval entry $w.fDbg.v -textvariable D -width 1 -bd 0 -highlightthickness 0 eval pack $w.fDbg.m $w.fDbg.v -in $w.fDbg -side left eval menu $w.fDbg.m.menu -activeborderwidth 0 $w.fDbg.m.menu add command -label {Incr} -command {incr D} $w.fDbg.m.menu add command -label {Decr} -command {incr D -1} $w.fDbg.m.menu add command -label {Quiet} -command {set D 1} $w.fDbg.m.menu add command -label {Silent} -command {set D 0} pack $w.fDbg -in $w -side right } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Here's a routine that appends a message to the .dbg.t.txt widget, # # if it exists, otherwise writes to stdout. Several applications that # # use this package also call [txtWin .dbg ...] to create the .dbg # # window, and for those apps, we write to the .dbg window. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc Dmsg {m} { if [winfo exists .dbg] { .dbg.t.txt insert end $m\n } else { puts $m } }