tkinter - 如何在 Tkinter 中更改按钮文本的大小
问题描述
import tkinter as tk
HEIGHT = 950
WIDTH = 650
root=tk.Tk()
canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
canvas.pack()
frame = tk.Frame(root, bg='#80c1ff')
frame.place(relx=0.5, rely=0.1, relwidth=0.75, relheight=0.1, anchor='n')
button = tk.Button(frame, text="Credit Score Checker", font=20)
button.place(relx=-0, relheight=1, relwidth=0.27)
button = tk.Button(frame, text="Financial Advisor", font=20)
button.place(relx=0.25, relheight=1, relwidth=0.27)
button = tk.Button(frame, text="Insurance Planner", font=20)
button.place(relx=0.5, relheight=1, relwidth=0.27)
button = tk.Button(frame, text="Goal Setter", font=20)
button.place(relx=0.75, relheight=1, relwidth=0.26)
lower_frame = tk.Frame(root, bg='#80c1ff', bd=10)
lower_frame.place(relx=0.5, rely=0.25, relwidth=0.75, relheight=0.6, anchor='n')
label = tk.Label(lower_frame, text="Summary of finances", bg='grey')
label.place(relx=0.5, rely=0, anchor='n', relwidth=0.9, relheight=1)
root.mainloop()
解决方案
而不是 font = 20 你可以使用
font = ("Helvetica",20,"bold")
#font=(font-family , font-size , "bold"/"italic")
您还可以执行以下操作
font = "Helvetica 20 bold"
对于 tkinter 的笔记,您可以访问 https://mycodenotein.netlify.app
推荐阅读
- c# - ListBox C# 中的可编辑 TextBox-es
- java - 成功和失败侦听器方法是否在后台线程上完成?
- javascript - 您可以在 google api 上的标记上将图像添加到内容框吗?
- java - 我无法在 recyclerview 上显示浮动操作菜单
- r - R中的奇偶一致性
- laravel - Laravel 5.x 和 7.x 认证中间件的区别
- javascript - 图像数组 ReactJs 响应式轮播
- sql-server - SQL CLR 中的 .Net Core 程序集
- scheme - 评估复合程序元循环“应用”的顺序
- apache-nifi - 在“ExtractText”调用的 Nifi 处理器“InvokeHttp”中,您在哪里编写 POST 请求的正文