简体   繁体   中英

Tkinter Button not resizing correctly according to the font size on a Mac

As you can see, I have some code here that creates a button with font that is size 48pt and is bold.

from tkinter import *
win = Tk()
button = Button(win, text="Play", font=("Helvetica 48 bold"))
button.pack()
win.mainloop()

However, when I run the code, the button isn't the right size. It resizes its width correctly, but for some reason the enlarged font stretches beyond the top and bottom limits of the button. Can anyone tell me how to do this?

This code will run as intended on Windows 8.1 with Python 3 (it did for me).

Perhaps a typo as well, but you need to add an ending ')' to this line:

button = Button(win, text="Play", font=("Helvetica 48 bold")

这是OSX特有的问题-OSX按钮确实要看起来像OSX按钮,并且不像在其他平台上那样可配置。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM