Tk Source Code

View Ticket
Login
Ticket UUID: 198376af5a37e6ff0846cd0e87348edef9bd23e6
Title: When moving tab position to different edge of notebook tabs may not appear
Type: Bug Version: 8.6 running on Linux Mint 21,2
Submitter: anonymous Created on: 2023-10-20 01:42:49
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2023-10-28 11:13:33
Resolution: Fixed Closed By: fvogel
    Closed on: 2023-10-28 11:13:33
Description:
When I try to move the tabs from the default position to position "s" the tabs do not appear but the space for the tab is there. The problem can be seen by executing the attached code and selecting the "Move to South" button. I expect to see the tabs just above the top button, but the space is blank. The tabs are not lost and can be moved with the other two buttons.
User Comments: fvogel added on 2023-10-28 11:13:33:
Merged in core-8-6-branch and trunk (conflicts fixed in the latter).

fvogel added on 2023-10-21 21:42:13:

Refined fix in [1bb22bb5], avoiding repeated calls to NotebookDoLayout() on macOS aqua.


fvogel added on 2023-10-21 13:14:19:

I have proposed a fix in [8730b178].

Interestingly enough, this fix works on Windows and Linux platforms, and it lets the new non-regression test [e3d216f3|notebook-198376af5a] pass on these two platforms while failing without the fix.

However, with the proposed fix, the test case given by the OP hangs on macOS aqua: NotebookDoLayout() is called repeatedly.


fvogel added on 2023-10-21 08:15:21:

A simple workaround is to add generation of a <Configure> event in the the -command option as follows:

    button .ts -text "Tab to South" -command \
"ttk::style configure TNotebook -tabposition s ; event generate .nb <Configure>"

But of course this is only a workaround.


oehhar added on 2023-10-20 10:40:49:

Thank you for the great report.

When pressing the button "Tab t0 South" on Tk 8.6.13 32 bit on Windows 64 bit:

  • the upper tab space is blank
  • The new tabs are painted below, but covered by the button "Tab to North"
  • Resizing the window displays the tabs correctly

It looks like a missing action on the configure event, or a missing issued configure event.

A screen-shot is attached.

Take care, Harald


anonymous added on 2023-10-20 01:48:31:
ttk::notebook .nb -width 200 -height 100
ttk::frame .nb.f1; # first page 
ttk::frame .nb.f2; # second page
.nb add .nb.f1 -text "One"
.nb add .nb.f2 -text "Two"
pack .nb
button .tn -text "Tab to North" -command \
"ttk::style configure TNotebook -tabposition n"
pack .tn
button .ts -text "Tab t0 South" -command \
"ttk::style configure TNotebook -tabposition s"
pack .ts
button .td -text "Default position" -command \
"ttk::style configure TNotebook -tabposition \"\""
pack .td

A workaround was provided by Alex P <[email protected]> in the form of the following:

proc ::TabOrientation {{pos ""}} {
  lassign [split [wm geometry .] x+] w h x y
  ttk::style configure TNotebook -tabposition $pos
  incr w 1
  wm geometry . ${w}x${h}+${x}+${y}
  update
  incr w -1
  wm geometry . ${w}x${h}+${x}+${y}
  update
}
ttk::notebook .nb -width 200 -height 100
ttk::frame .nb.f1; # first page
ttk::frame .nb.f2; # second page
.nb add .nb.f1 -text "One"
.nb add .nb.f2 -text "Two"
pack .nb -fill both -expand 1
button .tn -text "Tabs to North" -command {::TabOrientation n}
pack .tn
button .ts -text "Tabs to South" -command {::TabOrientation s}
pack .ts
button .td -text "Default position" -command ::TabOrientation
pack .td

about which he stated:

The above workaround looks like a silly attempt to fight a bug

Attachments: