Specifying colors for TNotebook Tabs

137 views
Skip to first unread message

don.ro...@gmail.com

unread,
Dec 1, 2012, 12:58:02 PM12/1/12
to
Hi,

I am trying to specify the background tab colors in a TNotebook, in particular the background color of the tab for the selected page, Here is an example of what I am trying to do:

toplevel .top
wm geometry .top 500x400+40+50;
update
.top configure -background wheat
ttk::style configure TNotebook -background wheat
ttk::style configure TNotebook.Tab -background plum
ttk::style configure TNotebook.Tab -activetabbackground green
ttk::notebook .top.nb -width 300 -height 200
.top.nb add [frame .top.nb.f1 -bg wheat] -text "First tab"
.top.nb add [frame .top.nb.f2 -bg wheat] -text "Second tab"
.top.nb add [frame .top.nb.f3 -bg wheat] -text "Third tab"
place .top.nb -in .top -x 100 -y 100

I want the tabs for unselected pages to be one color and the tab for the selected page to be another. The above code colors my tabs for unselected pages plum. But I have not found a way to make the color of the tab of the selected page different from the default gray. I have guessed a long list of possible option names but haven't found one that works.

Is it possible to specify the background color of the selected page in a notebook? If so how? It seems that the authors could not have overlooked that aspect of style, so I must be missing something! If I have missed some documentation, I apologize for taking your time.

Thanks in Advance,
Don

don.ro...@gmail.com

unread,
Dec 1, 2012, 10:11:32 PM12/1/12
to
On Saturday, December 1, 2012 9:58:02 AM UTC-8, don.ro...@gmail.com wrote:
> Hi,
>
>
>
> I am trying to specify the background tab colors in a TNotebook, in particular the background color of the tab for the selected page, Here is an example of what I am trying to do:
>
>
>
> toplevel .top
>
> wm geometry .top 500x400+40+50;
>
> update
>
> .top configure -background wheat
>
> ttk::style configure TNotebook -background wheat
>
> ttk::style configure TNotebook.Tab -background plum
>
> ttk::style configure TNotebook.Tab -activetabbackground green
>
> ttk::notebook .top.nb -width 300 -height 200
>
> .top.nb add [frame .top.nb.f1 -bg wheat] -text "First tab"
>
> .top.nb add [frame .top.nb.f2 -bg wheat] -text "Second tab"
>
> .top.nb add [frame .top.nb.f3 -bg wheat] -text "Third tab"
>
> place .top.nb -in .top -x 100 -y 100
>
>
>
> I want the tabs for unselected pages to be one color and the tab for the selected page to be another. The above code colors my tabs for unselected pages plum. But I have not found a way to make the color of the tab of the selected page different from the default gray. I have guessed a long list of possible option names but haven't found one that works.
> toplevel .top
wm geometry .top 500x400+40+50;
update
.top configure -background wheat
ttk::style configure TNotebook -background wheat
ttk::style configure TNotebook.Tab -background plum
ttk::style map TNotebook.Tab -background [list disabled plum selected green]
ttk::notebook .top.nb -width 300 -height 200
.top.nb add [frame .top.nb.f1 -bg wheat] -text "First tab"
.top.nb add [frame .top.nb.f2 -bg wheat] -text "Second tab"
.top.nb add [frame .top.nb.f3 -bg wheat] -text "Third tab"
place .top.nb -in .top -x 100 -y 100

>
>
> Is it possible to specify the background color of the selected page in a notebook? If so how? It seems that the authors could not have overlooked that aspect of style, so I must be missing something! If I have missed some documentation, I apologize for taking your time.
>
>
>
> Thanks in Advance,
>
> Don

I think that I solved my own problem. Consider the revised example:

toplevel .top
wm geometry .top 500x400+40+50;
update
.top configure -background wheat
ttk::style configure TNotebook -background wheat
ttk::style configure TNotebook.Tab -background plum
ttk::style map TNotebook.Tab -background [list disabled plum selected green]
ttk::notebook .top.nb -width 300 -height 200
.top.nb add [frame .top.nb.f1 -bg wheat] -text "First tab"
.top.nb add [frame .top.nb.f2 -bg wheat] -text "Second tab"
.top.nb add [frame .top.nb.f3 -bg wheat] -text "Third tab"
place .top.nb -in .top -x 100 -y 100

It seems to work and I am thrilled. It was found by random experimentation. I don't understand why the developer implemented this feature when he was too lazy to tell any one it was there let alone about how to use it. I often feel that deplorable documentation is the Achilles heel of Open Software.

Harald Oehlmann

unread,
Dec 3, 2012, 2:45:35 AM12/3/12
to
On Dec 2, 4:11 am, don.rozenb...@gmail.com wrote:
> It seems to work and I am thrilled.  It was found by random experimentation. I don't understand why the developer implemented this feature when he was too lazy to tell any one it was there let alone about how to use it.  I often feel that deplorable documentation is the Achilles heel of Open Software.

Don,

I am sorry for the experience of lack of documentation.
Indeed, ttk class style documentation is little. In addition it
depends on the style...
I personally used tkdoc.com to find the principes of investigation. It
is also a good idea to look to the source code (tcl folder lib/tk/ttk)
and check the widget and the stale files.

I personally took the habbit to publish my solutions on the wiki, when
I have found something.
I added your example here:
http://wiki.tcl.tk/20057

Thank you,
Harald
Reply all
Reply to author
Forward
0 new messages