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

ttk::notebook tab styling

3,871 views
Skip to first unread message

Julian H J Loaring

unread,
Feb 22, 2012, 4:20:56 AM2/22/12
to
Hi All

I am still mystified by how to discover what items can be restyled
with the ttk widgets :( In particular I am wanting to style the
individual tabs on a ttk::notebook (eg tab colours & font)

Trying:

ttk::style layout TNotebook
=>Notebook.client -sticky nswe

Reveals a Notebook.client, but what is it?

ttk::style layout Notebook.client
=>Layout Notebook.client not found

ttk::style element options TNotebook
=>
ttk::style element options Notebook.clients
=>
Both produces an empty result

Trying:

ttk::style element names
=>Horizontal.Scrollbar.leftarrow Vertical.Scale.slider Spinbox.uparrow
Horizontal.Scrollbar.thumb Horizontal.Scrollbar.trough
Horizontal.Scrollbar.rightarrow Combobox.field Sash.xsash
Vertical.Scrollbar.grip Menubutton.dropdown
Horizontal.Progressbar.pbar Vertical.Scrollbar.downarrow
Combobox.border Spinbox.field Spinbox.innerbg Combobox.rightdownarrow
Entry.background Horizontal.Scale.slider
ComboboxPopdownFrame.background Spinbox.background
Vertical.Scrollbar.thumb Vertical.Scrollbar.uparrow
Vertical.Scrollbar.trough error.field Horizontal.Scrollbar.grip
Entry.field Spinbox.downarrow error.innerbg Vertical.Progressbar.pbar

Reveals nothing obvious

What compunds my mystification is (from the wiki)

ttk::style configure SWTNotebook.TNotebook -tabposition sw -background
grey45

How do you discover that -tabposition and -background are valid
options; they are not in the man page. Alas, -background is not the
tab background.

Also from the wiki

ttk::style theme settings default {
ttk::style layout Plain.TNotebook.Tab null
}

Again, how does one know that there is a TNotebook.Tab element?


Arrggggggh !

Can anyone kindly boot me in the right direction

kind regards
Julian


Julian H J Loaring

unread,
Feb 23, 2012, 8:15:30 AM2/23/12
to
The following works for me

ttk::style configure TNotebook.Tab \
-font {arial 14 bold} \
-foreground blue

Not sure how to use introspection to discover TNotebook.Tab and its
options though :(


tombert

unread,
Feb 24, 2012, 3:02:13 AM2/24/12
to
Unfort. the elements lack a bit of documentation, but I can recommend to look into the source code in directory lib\tk8.5\ttk

There I collected the following options:

TNotebook:
-tabmargins, -tabposition, -padding, -background, -expand

TNotebook.Tab:
-padding, -background, -lightcolor, -expand


Julian H J Loaring

unread,
Feb 24, 2012, 8:39:57 AM2/24/12
to
Use the source, Luke...

Thanks I will have a browse because I need to find a way to make the
tabs look better when the position is at the bottom (s,sw,se); the tab
joins its frame at the lower edge rather than the top edge which just
looks wrong!

Julian H J Loaring

unread,
Feb 24, 2012, 5:16:54 PM2/24/12
to
I suppose what I am finding difficult is the switch from Tk where
everything was discoverable via introspection; create a widget and the
use configure to see what can be changed.

To introspect with Ttk you need to use a combination of configuring
the widget and using the ttk::style ensemble but it seems to me that
ttk::style doesn't reveal the whole picture and the hidden bits tend
to be the ones I am seeking.

ho hum

Uwe Klein

unread,
Feb 25, 2012, 2:59:45 AM2/25/12
to
Julian H J Loaring wrote:
> To introspect with Ttk you need to use a combination of configuring
> the widget and using the ttk::style ensemble but it seems to me that
> ttk::style doesn't reveal the whole picture and the hidden bits tend
> to be the ones I am seeking.
>
> ho hum

read up on OSes as airlines: Look for Apple Air ;-)

This is half unhelpfull, I know.

The other half says that ttk could be a paradigm change.
And like the content industry you try to use an old hammer
for these new corkscrew nails.

just a guess

uwe

Bull Dozier

unread,
Mar 31, 2016, 11:43:12 AM3/31/16
to
Individual tabs can not be controlled in a ttk notebook. You can set the background color of ALL the tabs and of any tab that is active, but you can't, for example, make a single tab have a different font or background color. There is simply no hook in the source code to style a tab individually, and the tab element is not exposed in the element stack.

This is a major bummer.

Kent

Francois Tonneau

unread,
Apr 9, 2016, 1:37:49 PM4/9/16
to
> Thanks I will have a browse because I need to find a way to make the
> tabs look better when the position is at the bottom (s,sw,se); the tab
> joins its frame at the lower edge rather than the top edge which just
> looks wrong!

The tabs do look bad if they are not at the top. I don't think there is any way to fix this with the standard themes, but if you build your own theme you can use bitmap elements that will look good in any position. Here is an example with a theme ("waldorf" Crunchbang) I wrote for GNU/Linux:

http://www24.zippyshare.com/v/eEhAqheR/file.html

By the way, the theme looks like any GTk+ software on my computer and also looks good on Windows 7 :-).

Christian Gollwitzer

unread,
Apr 9, 2016, 2:27:49 PM4/9/16
to
Am 09.04.16 um 19:37 schrieb Francois Tonneau:
> if you build your own theme you can use bitmap elements that will look good in any position. Here is an example with a theme ("waldorf" Crunchbang) I wrote for GNU/Linux:
>
> http://www24.zippyshare.com/v/eEhAqheR/file.html
>
> By the way, the theme looks like any GTk+ software on my computer and also looks good on Windows 7 :-).

Not bad! Have you planned to release this theme for use by others? Maybe
in the next core distribution of Tcl? It would be a great enhancement,
since the core themes on Linux look very oldfashioned.

How is the performance? I tried other bitmapped themes, and it seemed to
me, that they react slower than the "native" ones which build on
rectangles. Are tablelist trees also supported?

Christian

Brad Lanam

unread,
Apr 9, 2016, 2:57:53 PM4/9/16
to
See:

http://chiselapp.com/user/sgolovan/repository/ttk-themes/index
(This link is available on http://wiki.tcl.tk/14796 )

Both 'clearlooks' and 'arc' look good on Linux.

(Why did someone respond to a thread from 2012?)

Rich

unread,
Apr 9, 2016, 3:04:58 PM4/9/16
to
Brad Lanam <brad....@gmail.com> wrote:
> (Why did someone respond to a thread from 2012?)

Because 'someone' was a google groups user - and for some unknown
reason very many google groups users have a knack for replying to very
old threads as if they were new.

Francois Tonneau

unread,
Apr 9, 2016, 6:41:14 PM4/9/16
to
> Not bad! Have you planned to release this theme for use by others? Maybe
> in the next core distribution of Tcl? It would be a great enhancement,
> since the core themes on Linux look very oldfashioned.
>
> How is the performance? I tried other bitmapped themes, and it seemed to
> me, that they react slower than the "native" ones which build on
> rectangles. Are tablelist trees also supported?

I would be pleased if others used this theme :-)! These two screenshots:

http://www114.zippyshare.com/v/62qQf4SE/file.html

http://www13.zippyshare.com/v/DyhspaWk/file.html

show the same desktop application (written in pure Tcl) running on Linux Crunchbang (first link) and Windows 7 (second link). The theme includes ttk::treeview and ttk::panedwindow sashes.

Performance seems good to me on a netbook Asus Eee pc with 1 GB of ram at most. In contrast, I recall that some themes I found on the web (plastik or keramik?) were slow at repainting elements covered by top menus. Could this be due to the border size used in 'ttk::style element create'? If the central area of the raw image consists of 1 pixel, the image is slow to be repainted under stretching.

Francois Tonneau

unread,
Apr 9, 2016, 6:58:39 PM4/9/16
to
Once somebody answers to an old thread, somebody _else_ is bound to do it because the thread jumps to the top of the group list and with the time/date of the latest message showing. I genuinely thought the thread was new. Apologies in any case. I am new to google groups, comp.lang.tcl, and Tcl itself -- I think this is a great language :-)

Rich

unread,
Apr 9, 2016, 7:15:35 PM4/9/16
to
Alternately, given the terribleness of google groups all around, you
could register a free account at the Eternal September news-server
(http://www.eternal-september.org/) or make use of the free AIOE
news-servier (http://news.aioe.org/) (no registration required) and use
a real newsreader to access comp.lang.tcl (and the rest of Usenet).

Christian Gollwitzer

unread,
Apr 10, 2016, 7:52:32 AM4/10/16
to
Am 10.04.16 um 00:41 schrieb Francois Tonneau:
> I would be pleased if others used this theme :-)!

Well then please provide a download link. I'm sure that there is interest!

> These two screenshots:
>
> http://www114.zippyshare.com/v/62qQf4SE/file.html
>
> http://www13.zippyshare.com/v/DyhspaWk/file.html
>
> show the same desktop application (written in pure Tcl) running on
> Linux Crunchbang (first link) and Windows 7 (second link). The theme
> includes ttk::treeview and ttk::panedwindow sashes.

On Windows and OSX, there are very good default themes already, which
use the native widgets of the platform. My recommendaion & practice for
these two has always been "use ttk for everything, leave the defaults",
which results in reasonable applications which are accepted by the users
as "native". Only on Linux/X11, they *always* get it ("Tk, well, ugly!").

The only thing in your theme which I'd change is the red menu, I think
that is too strong, maybe to blueish/gray. But otherwise it looks very
modern. So yes, I'd definitely be interested. I'd vote to include this
as the default theme in the next release of Tcl.

How about licensing issues? Are you open to release it under the Tcl
license (BSD)? Are there any pixmaps which you have taken from somewhere
else?

> Performance seems good to me on a netbook Asus Eee pc with 1 GB of
> ram at most. In contrast, I recall that some themes I found on the
> web (plastik or keramik?) were slow at repainting elements covered by
> top menus. Could this be due to the border size used in 'ttk::style
> element create'? If the central area of the raw image consists of 1
> pixel, the image is slow to be repainted under stretching.

I tried plastik, which looks nice (KDE lookalike), but indeed had slow
performance. Maybe if the reason for the performance penalty can be
found, it might be possible to fix it in the Tk core.


Brad Lanam

unread,
Apr 10, 2016, 12:17:15 PM4/10/16
to
On Sunday, April 10, 2016 at 4:52:32 AM UTC-7, Christian Gollwitzer wrote:
> Am 10.04.16 um 00:41 schrieb Francois Tonneau:
> > Performance seems good to me on a netbook Asus Eee pc with 1 GB of
> > ram at most. In contrast, I recall that some themes I found on the
> > web (plastik or keramik?) were slow at repainting elements covered by
> > top menus. Could this be due to the border size used in 'ttk::style
> > element create'? If the central area of the raw image consists of 1
> > pixel, the image is slow to be repainted under stretching.
>
> I tried plastik, which looks nice (KDE lookalike), but indeed had slow
> performance. Maybe if the reason for the performance penalty can be
> found, it might be possible to fix it in the Tk core.

Is there a specific way you are testing performance?
I'm trying out the different themes in my application (I've got them all in
there and allow the user to choose), and I don't notice any slowdown.
Drawing 30+ comboboxes doesn't seem to be any slower.

I would add 'arc' and 'clearlooks' to the Tk core also.

Christian Gollwitzer

unread,
Apr 10, 2016, 2:44:11 PM4/10/16
to
Am 10.04.16 um 18:17 schrieb Brad Lanam:
> On Sunday, April 10, 2016 at 4:52:32 AM UTC-7, Christian Gollwitzer wrote:
>> Am 10.04.16 um 00:41 schrieb Francois Tonneau:
>>> Performance seems good to me on a netbook Asus Eee pc with 1 GB of
>>> ram at most. In contrast, I recall that some themes I found on the
>>> web (plastik or keramik?) were slow at repainting elements covered by
>>> top menus. Could this be due to the border size used in 'ttk::style
>>> element create'? If the central area of the raw image consists of 1
>>> pixel, the image is slow to be repainted under stretching.
>>
>> I tried plastik, which looks nice (KDE lookalike), but indeed had slow
>> performance. Maybe if the reason for the performance penalty can be
>> found, it might be possible to fix it in the Tk core.
>
> Is there a specific way you are testing performance?

Maybe I should try it on X11, sure, but under OSX (where it's
technically not needed), they are slow as hell. I run the demo.tcl from
the folder you gave me. Then I grab the right window border and resize
the window with the mouse. Under the aqua theme, it jumps a bit, but it
is still acceptible. Under the Keramik theme, there are jumps with ~1s.
Under arc, it seems to the user that the program is not reacting at all.
If I do the same test with a native App like Thunderbird, it runs fully
smooth.

I could even segfault Tk using this test, by resizing too fast. There
seems to be a race condition in the OSX Tk. Not sure how to hunt it
down, though.

> I'm trying out the different themes in my application (I've got them all in
> there and allow the user to choose), and I don't notice any slowdown.

I've uploaded videos from my system, so you can see yourself:

Thunderbird https://youtu.be/BDwtyVSYBUo
Tcl/Tk https://youtu.be/gcdfNIhtCtE

While resizing the Tcl program, the activity goes to 100%, so this is
really a CPU bound task inside Tk. OTOH I can't understand why blitting
pixel images needs so much CPU.

> I would add 'arc' and 'clearlooks' to the Tk core also.

Arc looks really nice, but it has the original pixmaps from Gtk+ and is
therefore under the GPL.

Christian


Brad Lanam

unread,
Apr 10, 2016, 2:57:23 PM4/10/16
to
I just tried it on a Mac and confirm the resizing is slow as you have shown.
'arc' doesn't seem any slower than the others to me. If there is no resizing
going on, the speed is quite reasonable (I am connected to the mac via gtkvncviewer, so the graphics are slow in the first place).

Resizing under X11 seems fine.

Resizing on Windows has a slight lag, but not so slow as the Mac.

Brad Lanam

unread,
Apr 10, 2016, 3:02:16 PM4/10/16
to
Actually, 'Plastik' is noticably slower than 'arc' on Windows when resizing.
Most of the other graphical themes have a slight slowness on Windows, but are usable.
0 new messages