Posted to tcl by Emiliano at Wed Aug 15 23:13:34 GMT 2007view pretty
proc ttk::text {wname args} { namespace eval text {} set tname $wname.txt entry $wname -state disabled -takefocus 0 bindtags $wname None_at_all eval ::text $tname $args $tname configure -borderwidth 0 -highlightthickness 0 bind $tname <<PrevWindow>> [format {tk::TabToWindow [tk_focusPrev %s];break} $wname] pack $tname -padx 2 -pady 2 -expand 1 -fill both uplevel #0 [list rename $wname ::ttk::text::$wname] uplevel #0 [list interp alias {} $wname {} $tname] bind $tname <FocusIn> [list ::ttk::text::$wname state focus] bind $tname <FocusOut> [list ::ttk::text::$wname state !focus] bind $tname <Destroy> [list destroy $wname] bind None_at_all <FocusIn> {tk::TabToWindow [tk_focusNext %W]} return $wname } pack [ttk::text .t -bg white -width 40 -height 15 ] -padx 10 -pady 10 pack [ttk::button .b -text "Hello"] -pady {0 10} ttk::setTheme clam
Comments
Posted by jenglish at Fri Aug 17 19:08:18 GMT 2007 [text] [code]
Suggestion: instead of using a [ttk::entry] widget as the wrapper, use a [ttk::frame] widget that's configured to look like an entry widget: [ttk::frame $wname -style TEntry]. That way you won't need to disable all of the built-in entry widget behavior that's getting in the way (-takefocus 0, bindtags, etc.) Frame widgets work much better as containers, since that's what they were designed to do.