Tk Source Code

View Ticket
Login
Ticket UUID: 6020ee2d03c3ebcd6bcf16465a41873e4b5e3db
Title: Label of tab not showed completely
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2017-02-01 01:32:08
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 7 High Severity: Minor
Status: Closed Last Modified: 2017-05-02 18:28:19
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-05-02 18:28:19
Description:

The text of label is not showed completely. This bug happen on windows and on linux. I didn't tested on Mac

This is the code:

ttk::notebook .notebook
pack .notebook -expand true -fill both

frame .notebook.f1 -width 100 -height 100
.notebook add .notebook.f1
frame .notebook.f2 -width 100 -height 100
.notebook add .notebook.f2 -text {this is a label}

If I add a label with some chars (it seems that if I use only 1 char for the label of the first tab the problem persists), then the last tab is showed normal.

ttk::notebook .notebook
pack .notebook -expand true -fill both

frame .notebook.f1 -width 100 -height 100
.notebook add .notebook.f1 -text {some text here}
frame .notebook.f2 -width 100 -height 100
.notebook add .notebook.f2 -text {this is a label}

User Comments: fvogel added on 2017-05-02 18:28:19:
Thanks Koen for the further check. I have reverted the anonymous patch that has this drawback, and have merged to core-8-6-branch and trunk.

danckaert added on 2017-05-02 15:31:34:

Please don't replace (int) by floor(). It's applied to negative values here and that gives a different result. The intention was to round towards zero.

Try the following code:

ttk::notebook .nb
pack .nb -fill both -expand true
for {set i 0} {$i<20} {incr i} {
    .nb add [text .t$i] -text "Tab $i"
}
You will see that with the floor() version, the last tab shrinks with about 20 pixels before the other tabs start shrinking.


fvogel added on 2017-04-07 20:02:30:
Merged to core-8-6-branch and trunk.

fvogel added on 2017-04-06 20:02:48:

Thanks, I have committed this improved version of the fix, see [6cfe2c0c6c].


anonymous added on 2017-04-05 22:36:15:

Hi, I only want to add a little improvement to the patch. I am using floor() function instead of doing a casting. Also, instead of delta, maybe it's better to use fraction for example:

     int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
 
     if (nTabs > 0) {

	int difference = available - needed;
        double fraction = (double)difference / needed;
        double slack = 0;
 	int i;
        double ad;
 
        /* Ignore minTabWidth; it's ignored in TabRowSize() too. */
 	for (i = 0; i < nTabs; ++i) {
 	    Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);

            ad = slack + tab->width * fraction;
            tab->width += (int)ad;
            slack = ad - floor(ad);
 	}
     }
 }


fvogel added on 2017-03-31 21:33:48:

See [3089640fff].


fvogel added on 2017-02-01 18:05:40:

Does not happen for all styles, for instance with

ttk::style theme use classic
the tab label is completemy displayed (here on Vista).