Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

multi line ttk::entry

850 views
Skip to first unread message

AurovilleRadio

unread,
Mar 9, 2011, 1:31:23 AM3/9/11
to
I want a tiles ttk::text or better say multi line ttk::entry. I fail
to understand why entry does not support this feature for simple forms
that need to be filled with longer text data without any formatting. I
looked at the text widget and it makes things complicated as it does
not have the -textvariable -validatecommand and -validate that I use
with ttk::entry and it does not follow the Tile theme. What is the
best solution that will be the closest to multi line ttk::entry?

AurovilleRadio

unread,
Mar 11, 2011, 1:36:57 AM3/11/11
to

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...

Harald Oehlmann

unread,
Mar 11, 2011, 4:00:40 AM3/11/11
to
On 11 Mrz., 07:36, AurovilleRadio <avradion...@gmail.com> wrote:
> as no insights are coming then maybe a different approach. how can I
> change the text widget border color:

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

Emiliano

unread,
Mar 11, 2011, 11:05:45 AM3/11/11
to
On 11 mar, 03:36, AurovilleRadio <avradion...@gmail.com> wrote:
> 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.

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

Emiliano

unread,
Mar 11, 2011, 11:20:30 AM3/11/11
to
On 11 mar, 13:05, Emiliano <emilianogavi...@gmail.com> wrote:

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

AurovilleRadio

unread,
Mar 14, 2011, 11:21:28 PM3/14/11
to

works beautifully and looks natural. thanks

0 new messages