【发布时间】:2017-01-08 12:42:06
【问题描述】:
我正在尝试更改 Tkinter 中按钮的字体大小,因此它不会那么小。有没有人知道我可以做什么,这可能会产生我正在寻找的结果?当我可以用更少的文字简单明了地问一个问题时,为什么我需要这么多的文字来提问?!
from Tkinter import *
from tkFont import *
class App:
def __init__(self):
guiWindow = Tkinter.Tk()
guiWindow.wm_title("FooBar")
# Creates a custom font
customFont = Font(size=18)
# code to add widgets will go here
buttonFrame = Frame()
# colors the "ChangeLicense" button
color = '#005DA6'
# tells licenseChange what to do
def openLicenseChange():
print('Change License')
#button properties
licenseChange = Button(guiWindow,
command=openLicenseChange,
bd=20, bg=color, font=customFont,
text="Change License")
buttonFrame.pack(side="top", fill="x")
guiWindow.mainloop()
app=App()
【问题讨论】:
-
我不明白这个问题。您的代码确实创建了一个带有大字体的按钮。你有什么问题?当我运行您的代码时(并添加了
licenseChange.pack(),出现了一个 18pt 的大按钮。