This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2.7.8 ttk Button text display problem
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 2.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: les.bothwell, serhiy.storchaka, zach.ware
Priority: normal Keywords:

Created on 2014-07-21 20:22 by les.bothwell, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ttk_font.pdf les.bothwell, 2014-07-21 20:22 PDF showing captured images of problem
issue22026.tcl serhiy.storchaka, 2014-07-22 21:17
Messages (4)
msg223607 - (view) Author: Les Bothwell (les.bothwell) Date: 2014-07-21 20:22
My system: Windows 7 64 bit.  Python 2.7.8 (32 bit)
There's a problem with ttk button label text truncation when using large fonts on 2.7.8.  2.7.6 works Ok.  With 2.7.6, increasing the font size in a ttk style makes the button large enough to display the text properly.  With 2.7.8 the button seems to be large enough but the text is truncated on the right.  See attached file for pics.
Since issue 21665 is not closed yet, is this a side effect of ttk build problems?

This displays the problem..
from Tkinter import *
import ttk

from oxogame import *

class MainWindow(Frame):
    def __init__(self, master=None):
        " Initialise main window with controls "
        Frame.__init__(self, master)
        master.title('Font problem')
        ttk.Style().configure('Square.TButton', font='Arial 24 bold', width=1, height=1, padding=(6,0))

        ttk.Button(self, state=NORMAL, text='X', style='Square.TButton').pack(side=LEFT)
        ttk.Button(self, state=NORMAL, text='O', style='Square.TButton').pack(side=LEFT)
        self.pack(side=LEFT, fill=None, expand=0)

if __name__ == "__main__":
    root = Tk()
    root.resizable(0, 0)
    root.attributes("-toolwindow", 1)
    MainWindow(root).mainloop()
msg223655 - (view) Author: Les Bothwell (les.bothwell) Date: 2014-07-22 10:00
In my example, the import statement can be removed (dammit)
msg223674 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-07-22 17:08
I believe this is a change in Tk itself, I can get your 2.7.6 result with Python 2.7.8+ compiled against Tcl/Tk 8.5.2, and your 2.7.8 result with Python 2.7.6 compiled against Tcl/Tk 8.5.15.  I would guess that Tk is trying to avoid getting glyph in your padding and that you may need to work with centering somehow, but that's just wild speculation.

Serhiy, do you have any further insight?
msg223700 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-22 21:17
Indeed. I got different results with different versions of Tk. Here is Tcl script which demonstrates this.
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66225
2014-07-22 21:29:55zach.waresetstage: resolved
2014-07-22 21:17:43serhiy.storchakasetstatus: pending -> closed
files: + issue22026.tcl
messages: + msg223700
2014-07-22 17:08:19zach.waresetstatus: open -> pending

nosy: + serhiy.storchaka, zach.ware
messages: + msg223674

resolution: third party
2014-07-22 10:00:23les.bothwellsetmessages: + msg223655
2014-07-21 20:22:04les.bothwellcreate