chrstphrchvz / perl-tcl-ptk

Tcl::pTk - Interface to Tcl/Tk with Perl/Tk compatible syntax
https://metacpan.org/pod/Tcl::pTk
Other
8 stars 2 forks source link

wrong label background in ttkTixNoteBook on macOS Big Sur #9

Closed welleozean77 closed 1 year ago

welleozean77 commented 4 years ago

There is a background problem in widget running on macOS Big Sur. In the following:

use Tcl::pTk; use Tcl::pTk::ttkTixNoteBook; my $mw = MainWindow; my $int = $mw->interp;

my $nb_widget = $mw->ttkTixNoteBook()->pack(-expand=>1, -fill=>'both'); my $nb_page_01= $nb_widget->add("page1", -label=>'PAGE 1',); my $nb_page_02=$nb_widget->add("page2", -label=>'PAGE 2', );

$int->MainLoop;

the label background of the active tab remains white (instead of blue) and since the label font is white too, the text can not be read. Note that the same issue does NOT occur both in the Dark mode as well in pure Tcl/Tk.

Screenshot: https://ibb.co/sHFCZ8d

chrstphrchvz commented 4 years ago

I'll check if there's a hardcoded text color somewhere. I'm still not yet sure if I will get to try Big Sur on my old Macs. From screenshots I found online it looks like the selected tab background is supposed to be white under light mode:

chrstphrchvz commented 4 years ago

Welle, could you please confirm that the issue is present for the "Themed notebook" widget demo in widgetTclpTk?

chrstphrchvz commented 4 years ago

I notice a recent check-in that may be relevant: https://core.tcl-lang.org/tk/info/990a4e5dc1517c66

What version of Tcl/Tk did you observe this issue with? Have you tried reproducing it with recent core-8-6-branch?

welleozean77 commented 4 years ago

I am using TK: 8.6.10, quite recent.

The demo widget packed with TK 8.6.10 as an exe and run on the target machine with macOS Big Sur (my development machine is not Big Sur), produces the same result. It seems that the foreground (font) may be hardcoded since it is white when the tab is selected (while it should be black).

I am a bit confused too, since my code used ttkTixNoteBook, while the demo ttkNotebook (in any case, same result)

In Widget.pm I found in line 1723 "delete $args{'-inactivebackground'};" this the only reference to some colour I have found.

welleozean77 commented 4 years ago

I need to check it better. Apparently, there are indeed different behaviours depending on the Tk (always 8.6.10) I am using (blue background and white text, white background and white text). If you can provide me the link to the latest Tcl+Tk bundles, I'll be happy to give a try. I am using the ones here: https://www.tcl.tk/software/tcltk/download.html

chrstphrchvz commented 4 years ago

Unfortunately I'm not aware of prebuilt bundles for prerelease Tcl/Tk, although those might be a good idea if frequent Tcl/Tk releases are proving difficult. I have been building Tcl/Tk from source, although not into Mac bundles, and I'm not sure I know how to build bundles correctly.

Pinging Tcl/Tk Aqua developers (@culler, @codebykevin) and other users (@takamotoAI, @sl1200mk2): would anyone happen to have prebuilt bundles from recent core-8-6-branch they can share, or advice on building them?

codebykevin commented 4 years ago

Instructions for building a standalone bundle of Wish with the frameworks embedded can be found at http://wiki.tcl.tk/12987 - check for "embedded." It's just an extra build step after building from source.

chrstphrchvz commented 4 years ago

I am a bit confused too, since my code used ttkTixNoteBook, while the demo ttkNotebook (in any case, same result)

To summarize:

sl1200mk2 commented 4 years ago

Hi Christopher, building Tcl/Tk from source is over simple and takes 2 minutes each.

first build Tcl then Tk. for both, here are my command lines:

make -C macosx deploy CFLAGS="-O2 -mmacosx-version-min=10.9"

sudo make -C macosx install-deploy

if you want the debug version of both just replace deploy by develop

++

Nicolas

Le lun. 7 sept. 2020 à 17:40, Christopher Chavez notifications@github.com a écrit :

I am a bit confused too, since my code used ttkTixNoteBook, while the demo ttkNotebook (in any case, same result)

To summarize:

  • In Perl/Tk there was Tk::NoteBook https://metacpan.org/pod/Tk::NoteBook, based on the Tix notebook widget http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm. In Tcl::pTk, this is available as Tcl::pTk::NoteBook if the Tix Tcl/Tk extension is present.
  • Tcl/Tk 8.5+ (and Tile for Tcl/Tk 8.4) has ttk::notebook https://www.tcl.tk/man/tcl/TkCmd/ttk_notebook.htm, which has some differences from the older, unmaintained Tix notebook. In Tcl::pTk, this is available as Tcl::pTk::ttkNotebook.
  • ttkTixNoteBook is a compatibility wrapper for ttkNotebook: it tries to allow existing Tk::NoteBook usage to instead use ttkNotebook, by remapping/discarding various functions/options. Unless you intend to keep code compatible with Perl/Tk Tk::NoteBook, you might consider using ttkNotebook directly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrstphrchvz/perl-tcl-ptk/issues/9#issuecomment-688399758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASIFYIWUPB5CU6GKAFEMTSET5HDANCNFSM4Q4NFYGQ .

culler commented 4 years ago

The systemSelectedTabTextColor on the current core-8-6-branch depends on the macOS version. It is white in 10.7-10.15 and it is the same as systemTextColor in 10.6 and 11.1. In 11.1 that color adapts to light or dark mode.

Apple changed the design of the notebook tabs for Big Sur. The new tab bar is a long rounded rectangle with text for the tabs but no other decorations. The color of the tab bar is a gray which contrasts slightly with the background, as with a GroupBox or ttk::labeledframe. (The contrast was always subtle, but in Big Sur it is barely noticeable.) The active tab looks like a normal button. The tabs are no longer colored with the systemControlAccentColor.

In the core-8-6-branch the HIToolbox library is used to draw the tabs. Remarkably, it seems that Apple is continuing to update that library for 11.1 even though they refuse to make it support the DarkAqaa appearance. So Tk does the best it can to make the tabs usable in dark mode. The mac_styles branch draws the tabs itself, and they adapt to dark mode more or less as the native ones do.

The other cosmetic change for Big Sur that I have noticed so far is that the disclosure triangle is no longer a triangle. Now it is a chevron, and it is quite hard to see as drawn by HIToolbox (even in light mode). The mac_styles branch will provide a chevron at some point.

Notebook screenshots from Big Sur: HiTools light

HIToolsLight

HiTools dark

HIToolsDark

mac_styles light

mac_stylesLight

mac_styles dark

mac_StylesDark
welleozean77 commented 4 years ago

Thank you all for the replies. Christopher, compiling Tcl/Tk is indeed easy on macOS. I normally use:

export ver="8.6.10" make -C tcl8.6.10/macosx embedded CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=10.11" make -C tk8.6.10/macosx embedded CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=10.11"

Now, with the latest release of Tcl/Tk (https://www.tcl.tk/software/tcltk/download.html) I get the problem, both with Tcl::pTk and with pure Tcl/Tk (Wish).

button .hello -text "Quit" -command { exit } pack .hello

ttk::notebook .nb .nb add [frame .nb.f1] -text "First tab" .nb add [frame .nb.f2] -text "Second tab" .nb select .nb.f2 pack .nb

wm title . "Quit button" wm geometry . 350x250+300+300

The foreground (font) is white. I am not aware of the "mac_styles branch" which must be an unreleased version. I get it will included in the latest version at some point. Where can I get it to try it out? Does the "mac_styles branch" is uptodate besides the specific Mac stuff? I.e can it be more or less safely be used in production, or it is still highly 'experimental'?

Thank you

chrstphrchvz commented 4 years ago

All Tcl/Tk code development happens in the Fossil repository at https://core.tcl-lang.org/tk, and this is where development branches (core-8-6-branch, mac_styles, etc.) reside. The fossil client can be used to retrieve the code as it is updated, or the repository contents at a specific check-in ("commit") can be downloaded using a web browser.

(I personally retrieve the development code from the read-only GitHub mirror at https://github.com/tcltk/tk instead, since I am more familiar with git, and like to use various git-powered code archeology tools—e.g. GitLens for Visual Studio Code. However few Tcl/Tk developers are familiar with the GitHub mirror, and would probably only recommend using the Fossil repository.)

core-8-6-branch tracks the work that will go into Tk 8.6.x releases; the trunk branch is for Tk 8.7. The mac_styles branch is for ongoing major rework of widget appearance in Tk Aqua; it is still somewhat experimental, and is unlikely to be published in a release soon (it might have to wait until Tk 8.7 due to the amount of changes or new features). But there appears to be at least one person actively using it in their app.

welleozean77 commented 4 years ago

I am a bit lost in Fossil. Can someone point me to a branch that is fairly updated (at least https://www.tcl.tk/software/tcltk/download.html) but has the ttk::notebook updated as in the screenshot of @culler ? I compiled the read-only GitHub mirror at https://github.com/tcltk/tk, but the issue doesn't seem to be solved there. Thank you.

sl1200mk2 commented 4 years ago

Hi, this one is the mac_styles branch https://core.tcl-lang.org/tk/info/2603d1554b760bc9

++

Le sam. 12 sept. 2020 à 20:45, welleozean77 notifications@github.com a écrit :

I am a bit lost in Fossil. Can someone point me to a branch that is fairly updated (at least https://www.tcl.tk/software/tcltk/download.html) but has the ttk::notebook updated as in the screenshot of @culler https://github.com/culler ? I compiled the read-only GitHub mirror at https://github.com/tcltk/tk, but the issue doesn't seem to be solved there. Thank you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrstphrchvz/perl-tcl-ptk/issues/9#issuecomment-691529601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASIFYQD3YXASA5RNMSGXDSFO6VBANCNFSM4Q4NFYGQ .

sl1200mk2 commented 4 years ago

which need to be linked against a recent Tcl version like this one (core-8.6 branch) https://core.tcl-lang.org/tcl/info/f61ad2f6f3a9bb24

Le sam. 12 sept. 2020 à 20:49, nicolas bats sl1200mk2@gmail.com a écrit :

Hi, this one is the mac_styles branch https://core.tcl-lang.org/tk/info/2603d1554b760bc9

++

Le sam. 12 sept. 2020 à 20:45, welleozean77 notifications@github.com a écrit :

I am a bit lost in Fossil. Can someone point me to a branch that is fairly updated (at least https://www.tcl.tk/software/tcltk/download.html) but has the ttk::notebook updated as in the screenshot of @culler https://github.com/culler ? I compiled the read-only GitHub mirror at https://github.com/tcltk/tk, but the issue doesn't seem to be solved there. Thank you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrstphrchvz/perl-tcl-ptk/issues/9#issuecomment-691529601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASIFYQD3YXASA5RNMSGXDSFO6VBANCNFSM4Q4NFYGQ .

welleozean77 commented 4 years ago

Thank you, Nicolas. I compiled the mac_style that you pointed to. On my Big Sur it produces a usable ttk::notebook (although different from Culler's one, since the selected tab still has blue background and white foreground). Preliminary tests, however, made the app crash (bug report filed at Tk Source), so this branch is still not usable for me.

I posted in Tcl/Tk Google group a question (https://groups.google.com/g/comp.lang.tcl/c/NOQBXCWsec4) on how to manually modify the colours of the Notebook tabs in order to keep using 8.6.10 on Big Sur (that seems to work fine for me besides the Notebook issue). Unfortunately, I have not been able to do it on a macOS.

chrstphrchvz commented 4 years ago

I posted in Tcl/Tk Google group a question (https://groups.google.com/g/comp.lang.tcl/c/NOQBXCWsec4) on how to manually modify the colours of the Notebook tabs in order to keep using 8.6.10 on Big Sur (that seems to work fine for me besides the Notebook issue). Unfortunately, I have not been able to do it on a macOS.

See my reply—I doubt it can be done.

chrstphrchvz commented 1 year ago

Closing: the original issue should have been resolved as of Tk Aqua 8.6.11.