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

how to create a ttk::treeview without a border?

1,211 views
Skip to first unread message

Bryan Oakley

unread,
Dec 20, 2007, 3:46:45 PM12/20/07
to
How can I create a ttk::treeview widget without a border? The following
yields unsatisfactory results on windows but the following is my best
guess so far (emphasis on "guess"). I've tried several variations of
layouts but none seem to work. This, with tile 0.8 and tk 8.5b3.

package require Tk 8.5
proc main {} {
ttk::style layout FlatTree {
Treeview.padding -sticky nsew -border 0 -children {
Treeview.treearea -sticky nswe -border 0 -expand true
}
}


ttk::frame .f
pack .f -side top -fill both -expand true -padx 10 -pady 10

ttk::treeview .tree \
-style FlatTree \
-show tree
pack .tree -in .f -side top -fill both -expand true

set parent [.tree insert {} end -text Root -open true]
.tree insert $parent end -text One
.tree insert $parent end -text Two
.tree insert $parent end -text Three

}

main


--
Bryan Oakley
http://www.tclscripting.com

Joe English

unread,
Dec 21, 2007, 8:56:09 PM12/21/07
to
Bryan Oakley wrote:
> How can I create a ttk::treeview widget without a border? The following
> yields unsatisfactory results on windows but the following is my best
> guess so far (emphasis on "guess").

What do you find unsatisfactory about it?

It looks to me like it does what you want (no border),
the only thing I see wrong is that the fill color behind
items doesn't match that of the blank region below.

Haven't tested on Windows, is it only a problem there?

I'd also suggest using "Flat.Treeview" as the style name
instead of "FlatTree"; the former will inherit all the
other Treeview settings (and there are plenty) defined
in the theme.


--Joe English

Bryan Oakley

unread,
Dec 22, 2007, 12:37:53 AM12/22/07
to
Joe English wrote:
> Bryan Oakley wrote:
>
>>How can I create a ttk::treeview widget without a border? The following
>>yields unsatisfactory results on windows but the following is my best
>>guess so far (emphasis on "guess").
>
>
> What do you find unsatisfactory about it?
>

When there aren't enough items in the treeview to fill the widget, the
area below the last item takes a different background color.


> It looks to me like it does what you want (no border),
> the only thing I see wrong is that the fill color behind
> items doesn't match that of the blank region below.

Bingo. Oddly, with the border, the border fills the whole region and the
background looks fine. When I turn the border off, that's when I get the
blank region below which is highly undesireable.

>
> Haven't tested on Windows, is it only a problem there?
>

I think so. Last I recall, it looked find on my mac when I was creating
it. A week or two passed, I tried running it on windows, and that's when
I noticed it didn't look right. I haven't tried it on *nix.

> I'd also suggest using "Flat.Treeview" as the style name
> instead of "FlatTree"; the former will inherit all the
> other Treeview settings (and there are plenty) defined
> in the theme.

Thanks for the hint.

0 new messages