as no insights are coming then maybe a different approach. how can I
change the text widget border color:
text .w.text - -height 3 -background white -relief solid -border 1 -
wrap word
the border is black which the tile entry border is blue by default. I
want the text to behave as similar as possible to the tiles themes.
The current need for both tile and non tile widget seems a bit
clumsy...
Hi,
I am sorry that you experienced no answer.
If the border is the issue, I have seen a brilliant posting by
Wojciech:
It is in the discussion section of http://wiki.tcl.tk/Ttk
The idea is to use a Ttk frame around a Tk widget.
Might this help you ?
If you want to "emulate" Ttk for Tk widgets, you may look to the work
of Johan Oberdorfer on Tile Bwidget.
The paper and slides on the EuroTCL conference tell about it:
http://www.eurotcl.org/2010/schedule.html
Hope this helps,
Harald
This is the code I've been using to wrap Tk widgets inside a Ttk
border.
# =================================================================
package require Tcl 8.5
package require Tk
namespace eval ::ttk {
bind Wrapframe <FocusIn> {%W#border state focus}
bind Wrapframe <FocusOut> {%W#border state !focus}
}
# wraps a plain Tk widget inside a ttk frame
proc ::ttk::WrapWidget {class path args} {
# handle the args
set args [dict replace $args \
-background white \
-borderwidth 0 \
-highlightthickness 0]
set args [dict remove $args -bg -bd]
# real widget
set rw $path.$class
# create the container frame and the widget
frame $path -style TEntry -class Wrapframe
::$class $rw {*}$args
bindtags $rw [list $path $rw Text [winfo toplevel $path] all]
# rename the container widget cmd and install
# a proxy cmd to the real one
rename ::$path ::${path}#border
interp alias {} $path {} ::ttk::WrapProxy $rw
pack $rw -expand 1 -fill both -padx 2 -pady 2
# adjust the select{fore|back}ground with the theme
bind $rw <<ThemeChanged>> [list apply {rw {
set sb [ttk::style configure . -selectbackground]
set sf [ttk::style configure . -selectforeground]
$rw configure -selectbackground $sb
$rw configure -selectforeground $sf
}} $rw]
after idle [list after 0 [list \
event generate $rw <<ThemeChanged>>]]
return $path
}
proc ::ttk::WrapProxy {w args} {
# prevent the border window to take focus
if {[lindex $args 0] eq "cget" &&
[lindex $args 1] eq "-takefocus"} {
return 0
}
$w {*}$args
}
interp alias {} ::ttk::text {} ::ttk::WrapWidget text
interp alias {} ::ttk::listbox {} ::ttk::WrapWidget listbox
interp alias {} ::ttk::canvas {} ::ttk::WrapWidget canvas
# demo
pack [ttk::text .t -width 20 -height 4] -padx 6 -pady 6
pack [ttk::entry .e -width 20] -padx 6 -pady 6
after 2000 {ttk::setTheme clam}
# =================================================================
If you need (or want) a -textvariable for text widgets,
see http://wiki.tcl.tk/1917
As for validation, you can use the excellent wcb package,
see http://www.nemethi.de/
Regards
Emiliano
Oops, there is a bug in the code I posted. Replace the "Text" in
the line
> bindtags $rw [list $path $rw Text [winfo toplevel $path] all]
for "[string totitle $class]"
Regards
Emiliano
works beautifully and looks natural. thanks