不能在 Tkinter 中使用 CenturyGothic 字体
Can't use CenturyGothic font with Tkinter
我想以 Tkinter 形式使用 CenturyGothic,但它不会更改字体...
我的代码:
import tkinter
import datetime
import time
app = tkinter.Tk()
app.title("Clock")
app.geometry("1280x720")
app.minsize(640,480)
def middle_screen():
w = 1280
h = 720
ws = app.winfo_screenwidth()
hs = app.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
app.geometry('%dx%d+%d+%d' % (w, h, x, y))
middle_screen()
app.configure(bg='white')
CurrentTime = str(datetime.datetime.now().strftime("%H"+":"+"%M"))
label_time = tkinter.Label(app, text=CurrentTime, bg='white', fg='black')
label_time.configure(font='GothicCentury 48 bold')
label_time.pack()
app.mainloop()
结果:
它应该是什么:
试试这个:
label_time.configure( font=("Century Gothic", 48, 'bold'))
我想以 Tkinter 形式使用 CenturyGothic,但它不会更改字体...
我的代码:
import tkinter
import datetime
import time
app = tkinter.Tk()
app.title("Clock")
app.geometry("1280x720")
app.minsize(640,480)
def middle_screen():
w = 1280
h = 720
ws = app.winfo_screenwidth()
hs = app.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
app.geometry('%dx%d+%d+%d' % (w, h, x, y))
middle_screen()
app.configure(bg='white')
CurrentTime = str(datetime.datetime.now().strftime("%H"+":"+"%M"))
label_time = tkinter.Label(app, text=CurrentTime, bg='white', fg='black')
label_time.configure(font='GothicCentury 48 bold')
label_time.pack()
app.mainloop()
结果:
它应该是什么:
试试这个:
label_time.configure( font=("Century Gothic", 48, 'bold'))