For Programmers: Free Programming Magazines  


Home > Archive > Tcl > December 2007 > how to create a ttk::treeview without a border?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to create a ttk::treeview without a border?
Bryan Oakley

2007-12-20, 10:13 pm

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

2007-12-21, 10:12 pm

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

2007-12-22, 4:25 am

Joe English wrote:
> Bryan Oakley wrote:
>
>
>
> 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 w 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.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com