Posted to tcl by Emiliano at Wed Aug 15 23:13:34 GMT 2007view raw

  1. proc ttk::text {wname args} {
  2. namespace eval text {}
  3. set tname $wname.txt
  4.  
  5. entry $wname -state disabled -takefocus 0
  6. bindtags $wname None_at_all
  7.  
  8. eval ::text $tname $args
  9. $tname configure -borderwidth 0 -highlightthickness 0
  10. bind $tname <<PrevWindow>> [format {tk::TabToWindow [tk_focusPrev %s];break} $wname]
  11.  
  12. pack $tname -padx 2 -pady 2 -expand 1 -fill both
  13.  
  14. uplevel #0 [list rename $wname ::ttk::text::$wname]
  15. uplevel #0 [list interp alias {} $wname {} $tname]
  16.  
  17. bind $tname <FocusIn> [list ::ttk::text::$wname state focus]
  18. bind $tname <FocusOut> [list ::ttk::text::$wname state !focus]
  19. bind $tname <Destroy> [list destroy $wname]
  20.  
  21. bind None_at_all <FocusIn> {tk::TabToWindow [tk_focusNext %W]}
  22.  
  23. return $wname
  24. }
  25.  
  26. pack [ttk::text .t -bg white -width 40 -height 15 ] -padx 10 -pady 10
  27. pack [ttk::button .b -text "Hello"] -pady {0 10}
  28. 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.