Tkinter 字体类型

转载:https://blog.csdn.net/hepu8/article/details/88833912

 

 

 

 1 # -*- coding: utf-8 -*-
 2 import tkinter as tk  #装载tkinter模块,用于Python3
 3 import  tkinter.font   as  tkFont  #导入Tkinter字体模块
 4 
 5 root=tk.Tk()  #创建Tkinter主窗口
 6 root.title("Tkinter字体演示")
 7 
 8 helv36 = tkFont.Font ( family="Helvetica",size=36, weight="bold",slant= "italic"  ,underline=1) #创建字体对象
 9 w = tk.Label(root, text="Tkinter字体演示", font=helv36) #创建Labkel部件 
10 w.pack()  #放置部件
11 
12 f = tkFont.Font(family="times", size=30, weight="normal",slant= "roman",overstrike=1 )
13 w = tk.Label(root, text="Hello, world", font=f)
14 w.pack()
15 
16 w = tk.Button(root, text="Quit!", command=root.destroy)
17 w.pack()
18 
19 fb = tkFont.Font(font=w["font"]).copy()
20 fb.config(weight="bold")
21 fb.config(size=20)
22 w.config(font=fb)
23 
24 root.mainloop()

 

posted @ 2021-09-22 17:18  linbo.yang  阅读(806)  评论(0编辑  收藏  举报