Tk Source Code

View Ticket
Login
Ticket UUID: cf296ac849da8ab0e02f4d62f31123b93d7625b6
Title: macOS: ttk::notebook tabs
Type: RFE Version: trunk
Submitter: nab Created on: 2025-10-22 02:10:41
Subsystem: 02. Appearance Assigned To: marc_culler
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-03-24 07:55:31
Resolution: Fixed Closed By: nobody
    Closed on:
Description:
Hi Marc,
I've started to use ttk::notebook in my app and there's something wrong with how tabs are displayed.
you can see this with the widget tour / special widgets for macOS
specifically in dark mode.

I'm attaching 3 picts to this ticket where the one called actualCode is as it is now. as you can see the latest tab is truncated.

playing with macosx/ttkMacOSXTheme.c in function DrawTab11(), if I set 
 clipRect.size.width += 5;
in the if (!(state & TTK_STATE_FIRST)) condition, it's better, last tab is not truncated.
this is the pict revisedClip

now if I completely change bounds and clip like that:
    if (!(state & TTK_STATE_FIRST)) {
        clipRect.origin.x += 0.5;
        clipRect.size.width -= 0.5;
        bounds.origin.x += 0.5;
        bounds.size.width -= 0.5;
	}
	if (!(state & TTK_STATE_LAST)) {
        clipRect.size.width -= 0.5;
        bounds.size.width -= 0.5;
	}

tabs are well displayed (not truncated) and not overlapping. it's the pict called revisedBounds.
last one is my favorite 

best regards,
nicolas
User Comments: jan.nijtmans added on 2026-03-24 07:55:31:

> But we should wait for Marc's opinion, and until then keep the ticket open

Marc, can you comment?


nab added on 2026-03-24 07:10:58:
Hi,
does this thing can be merged to trunk ?


best regards,
nicolas

nab added on 2025-12-17 22:02:20:
Csaba have found (and I can confirm) that removing whole bounds and clip gives perfect result.

here's the diff :
--- /Users/nico/Downloads/tk-20251217213734-8523dc14b0/macosx/ttkMacOSXTheme.c	2025-12-17 22:37:34
+++ /Users/nico/daylight/lib/distrib/tk-20251217194336-8d7ed4ad27/macosx/ttkMacOSXTheme.c	2025-12-17 22:55:17
@@ -1551,16 +1551,6 @@
 	 * rounded rectangle behind the entire tab bar.
 	 */
 
-	if (!(state & TTK_STATE_FIRST)) {
-	    clipRect.origin.x -= 5;
-	    bounds.origin.x -= 5;
-	    clipRect.size.width += 5;
-	    bounds.size.width += 5;
-	}
-	if (!(state & TTK_STATE_LAST)) {
-	    clipRect.size.width += 5;
-	    bounds.size.width += 5;
-	}
 	CGContextSaveGState(context);
 	CGContextClipToRect(context, clipRect);
 	DrawGroupBox(bounds, context, tkwin, 3, NO);

it would be very nice to have those changes in trunk

++
nicolas

nab added on 2025-11-22 09:34:04:
Hi Marc,

would you mind give a try to this please.

best regards,
nicolas

nab added on 2025-11-12 10:04:24:
Hi Csaba,
thank you for taking care of this.

With your code, tabs are overlapping (here on macOS26).
I still prefer my version :)

best regards,
nicolas

nemethi (claiming to be Csaba Nemethi) added on 2025-11-11 15:55:18:

The same fix is now in trunk, too (see [e2e88a72]). But we should wait for Marc's opinion, and until then keep the ticket open.


nemethi (claiming to be Csaba Nemethi) added on 2025-11-09 19:01:12:

A couple of remarks:

  1. It is not relevant at all whether the dark mode or light mode is active.
  2. Nicolas, you can get the effect resulting from your 2nd proposal in a much simpler way: just comment out the two if statements by inserting  #if 0  before the first if and #endif after the 2nd one.  The resulting GUI looks even better than the one shown in your screenshot revisedBounds.png.  However, this look differs from what you can see, e.g., in the "Trackpad" page of the System Settings.  The two if statements make sure that the function draws a Group Box in which "the segments fit together to form a long rounded rectangle behind the entire tab bar", as stated in the comment preceding this code.  With your 2nd proposal or by just deactivating the two if statements, the result no longer corresponds to what is stated in this comment and no longer has the aqua-specific native look.  Consequently, I doubt that your 2nd proposal could be the way to go.  But let's wait for Marc's opinion.


nemethi (claiming to be Csaba Nemethi) added on 2025-11-09 14:01:57:

Nicolas, I have committed your change that results in the screenshot revisedClip.png to the core-9-0-branch only (see [0dfc6cb1]). The main branch (trunk) is currently broken, hence any new commit to it should be postponed until it is usable again.

Your second proposal (resulting in the screenshot revisedBounds.png looks quite promising, but IMHO we should wait for Marc before taking any further action.


nab added on 2025-10-23 14:04:09:
Hi Marc,
I don't know, I never use light mode in my app... maybe it's just less obvious.

++

marc_culler (claiming to be Marc Culler) added on 2025-10-23 13:54:42:
Hi Nicolas, that looks like an improvement.

I don't understand why dark mode would behave any differently than lignt
mode.  What do you think accounts for that? Is there actually a difference?

Attachments: