Tk Source Code

View Ticket
Login
2026-04-14
16:45 • Ticket [23f52946] Rotated text for tk labels status still Open with 4 other changes artifact: 41b38b49 user: nemethi
16:41 • Closed ticket [01153381]: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*" plus 5 other changes artifact: 7d0f0b26 user: nemethi
16:40 • Ticket [01153381]: 4 changes artifact: fb4db070 user: nemethi
16:30
Fix for [0115338117]: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*". check-in: 4b645f47 user: csaba tags: 23f52946-rotated-text
15:57 • Ticket [01153381] Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*" status still Open with 3 other changes artifact: 7ed3e1c6 user: chw
15:46 • Ticket [01153381]: 4 changes artifact: 3b2295bd user: nemethi
15:31
Fix for [0115338117]: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*". check-in: 066c5134 user: csaba tags: core-9-0-branch
08:24 • Ticket [01153381] Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*" status still Open with 4 other changes artifact: cd0bcec8 user: nemethi
2026-04-13
19:57
Fix for [0115338117]: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*". check-in: d64f145a user: csaba tags: core-8-6-branch
12:54 • Ticket [01153381] Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s* status still Open with 4 other changes artifact: d1a1acff user: nemethi
12:29
Fix for [0115338117]: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*". check-in: 9a851511 user: csaba tags: trunk, main
2026-04-12
05:10 • Ticket [01153381] Flip ttk:: notebook tab states "first" and "last" for "-tabplacement e*|s* status still Open with 3 other changes artifact: 4eb98b49 user: chw
2026-04-11
16:20 • Ticket [01153381]: 4 changes artifact: d1131aa5 user: nemethi
07:58 • Ticket [01153381]: 3 changes artifact: 718ea217 user: chw
2026-04-10
18:20 • Add attachment nbtest8.tcl to ticket [01153381] artifact: 5f55d7d0 user: chw
18:20 • Ticket [01153381] Flip ttk:: notebook tab states "first" and "last" for "-tabplacement e*|s* status still Open with 3 other changes artifact: 0bae6b70 user: chw
10:43 • Ticket [01153381]: 3 changes artifact: 3bb1e966 user: chw
2026-04-09
12:20 • Ticket [01153381]: 4 changes artifact: 503102d1 user: oehhar
12:18 • Ticket [23f52946] Rotated text for tk labels status still Open with 4 other changes artifact: a61ae487 user: oehhar
11:44 • Ticket [01153381] Flip ttk:: notebook tab states "first" and "last" for "-tabplacement e*|s* status still Open with 4 other changes artifact: 08a1c50f user: nemethi
09:47 • Add attachment nbtest.tcl to ticket [01153381] artifact: 214056fa user: nemethi
2026-04-08
18:21 • Ticket [01153381] Flip ttk:: notebook tab states "first" and "last" for "-tabplacement e*|s* status still Open with 3 other changes artifact: 50c2aed8 user: chw
14:39 • Ticket [01153381]: 5 changes artifact: 7f62b246 user: nemethi
14:36 • Add attachment nbtest.tcl to ticket [01153381] artifact: 02214e61 user: nemethi
14:34 • Add attachment nbtest_clam_GOD.png to ticket [01153381] artifact: 8473ce82 user: nemethi
14:31 • Add attachment nbtest_clam_BAD.png to ticket [01153381] artifact: 7f687a33 user: nemethi
14:30 • New ticket [01153381] Flip ttk:: notebook tab states "first" and "last" for "-tabplacement e*|s*. artifact: 09c956df user: nemethi

Ticket UUID: 011533811758269de23a3e874f3ca9f326bab1f3
Title: Flip ttk::notebook tab states "first" and "last" for "-tabplacement e*|s*"
Type: Bug Version: all
Submitter: nemethi Created on: 2026-04-08 14:30:29
Subsystem: 88. Themed Tk Assigned To: nemethi
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-04-14 16:41:36
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-04-14 16:41:36
Description:

The ttk::notebook implementation (function TabState() in the file generic/ttk/ttkNotebook.c) pretends to set the tab state to first for the leftmost/topmost visible tab and to last for the rightmost/bottommost visible tab. (Tk versions 8.6 and earlier use the states user1 and user2 rather than first and last, which were added in Tk 8.7/9.0.). These tab state flags are used in the implementation of the themes clam, vista, and aqua.

It turns out that currently the function TabState() fails to do what it pretends if the value of the -tabplacement styling option starts with e or s, i.e., if the tabs are placed from right to left or from bottom to top. In the case of the clam theme this leads to the effect shown in the attached screenshot nbtest_clam_BAD.png, as reported by Christian Werner.

The fix, proposed by Christian and implemented in the branch notebook-fix, swaps the tab state flags first and last if the value of the -tabplacement styling option starts with e or s. In the case of the clam theme this leads to the effect shown in the attached screenshot nbtest_clam_GOOD.png. Besides this bugfix, the branch contains further notebook-related improvements for most built-in themes and adds the description of the styling option -tabplacement to the ttk_notebook manual.

User Comments: chw added on 2026-04-14 15:57:46:
¡Csaba, muchas gracias por tu valioso apoyo!

nemethi (claiming to be Csaba Nemethi) added on 2026-04-14 15:46:01:

Fixed by commits [9a851511], [066c5134], and [d64f145a] to main, core-9-0-branch, and core-8-6-branch.


chw added on 2026-04-12 05:10:04:
Csaba, much better approach! Now it looks quite good on Windows.
What about beginning to merge it starting with ye goode olde 8.6
steam engine? A TIP is not needed, since all these changes are
fixes of longstanding visual glitches.

nemethi (claiming to be Csaba Nemethi) added on 2026-04-11 16:20:01:

Christian, many thanks for your valuable input! I have just committed updated versions of the files ttkWinTheme.c and ttkWinVistaTheme.c.

In ttkWinTheme.c I made a few necessary changes, taking into account that the data of the rectangle to be passed to the DrawEdge() function depend on the sticky bit of the tab placement. With your original code there were missing pixels in the edge drawn by this function.

In ttkWinVistaTheme.c I chose a different approach than you. Besides being simpler, my code also eliminates a gap created by your method below the rightmost tab of the first notebook in the 3rd row of your example script.


chw added on 2026-04-11 07:58:39:
And here is the third attempt:

  https://androwish.org/home/info/545391a7744a669e

chw added on 2026-04-10 18:20:21:
An update to my first attempt, the second source, so to speak:

  https://androwish.org/home/info/57350cc5ec6ac5d4

This was necessary due to testing with your nbtest.tcl times 2,
which I attach as nbtest8.tcl to this ticket. It basically permutes
the -tabposition/-tabplacement options further, BTW still without
using all combinations times more than one row/column. So most
likely we have many little visual deficiencies to discover.

chw added on 2026-04-10 10:43:43:
Csaba, thanks for your improvements. However, the 3D border effect
needs more polishing, see my first attempt in this check-in

  https://androwish.org/home/info/e19da7dd70b66ca7

Affected themes: alt, classic, default, winnative. Untested is the
behavior for tabs distributed upon more rows/columns.

oehhar added on 2026-04-09 12:20:05:

More background to this ticket started is in [23f52946] (Androwish pointer).


nemethi (claiming to be Csaba Nemethi) added on 2026-04-09 11:44:32:

Christian, I have just uploaded a new version of the test script nbtest.tcl. Many thanks for your suggestion! The original version intentionally contained the line

set themeList [ttk::style theme names]

because the branch notebook-fix deals with built-in themes only. OTOH, the updated version can prove useful for testing the layout-related issues of third-party themes, too.

The styling options -tabposition and -tabplacement have been present in Ttk from the very beginning, but the original implementation of the notebook tabs simply ignored them, with the result that in all themes, the tab layout looked as expected on the north side of the widget only. In the last three years I made pretty many changes in both the C code and in the theme-specific scripts of the built-in themes, with the result that now the tabs look as expected on all 4 sides of the notebook widget. This has become even better due to your fix and to the further improvements made now in the notebook-fix branch. And, as you mentioned, the long-awaited vertical texts will improve the tab layouts even further and quite significantly.

To your question regarding the pixel-based themes: I would recommend to try the same method as the one applied to the built-in themes: After setting the notebook style's -tabposition option, invoke ttk::configureNotebookStyle, which in turn calls the proc theme::${theme}::configureNotebookStyle if present. That proc should invoke ttk::style configure and ttk::style map for theme-specific styling options like -padding, -tabmargins, or -expand.


chw added on 2026-04-08 18:21:13:
Thanks for bringing this topic forward, it will improve Tk's look
even more tremendously when Emiliano's angled text will be included
later.

The nbtest.tcl test script is very valuable. Would you improve it
by using "package require opt" right after "package require Tk"
(to update the package list) and setting the "themeList" variable
by "ttk::themes" instead of "ttk::style theme names" (to get all
packaged themes in the option menu).

Now for my observation: with many pixel-based themes (e.g. awarc,
awbreeze, awwinxpblue, keramik, plastik, droid) most non-standard
tab layouts are somehow broken. Do you have an idea how this can
be fixed, generally and hopefully easily?

nemethi (claiming to be Csaba Nemethi) added on 2026-04-08 14:39:26:

Attached the sample script nbtest.tcl and assigned the ticket to myself.


Attachments: