Python 如何在TkInter的函数中设置字体大小和文本字体?

Python 如何在TkInter的函数中设置字体大小和文本字体?,python,tkinter,Python,Tkinter,我不确定我到底出了什么问题,但我似乎不知道如何在“指令”功能中设置文本的字体大小 import random import time num = random.randint(1, 100) root = Tk() root.title("Mack's totally advanced Number Guesser!") root.geometry('404x300') ##root.resizable(False,False) root.configure(bg='black')

我不确定我到底出了什么问题,但我似乎不知道如何在“指令”功能中设置文本的字体大小

import random
import time


num = random.randint(1, 100)


root = Tk()

root.title("Mack's totally advanced Number Guesser!")
root.geometry('404x300')
##root.resizable(False,False)
root.configure(bg='black')



fontA = 'BigNoodleTitling'
fontSizeA = 20



def instructions():
    text = StringVar()
    welcomeLbl.grid_forget()
    instrButton.grid_forget()
    startButton.grid_forget()
    insL = Label(root, textvariable=text, fg='pink', bg='black').grid(row=2, pady=100)
    text.set('So you need instructions eh?')


titleLbl = Label(root)
titleLbl['borderwidth'] = (2)
titleLbl['relief'] = ('solid')
titleLbl['text'] = ("Mack's totally advanced Number Guessing Game!")
titleLbl['font'] = (fontA, fontSizeA)
titleLbl.grid(row=0, column=0)


welcomeLbl = Label(root, fg='white', bg='black')
welcomeLbl['text'] = ("Welcome Random Person")
welcomeLbl['font'] = (fontA, 30)
welcomeLbl.grid(row=2, column=0, pady=20)

instrButton = Button(root, command=instructions)
instrButton['text'] = ("Instructions")
instrButton['font'] = (fontA, fontSizeA)
instrButton.grid(row=3,column=0, sticky=N)

startButton = Button(root, fg='red')
startButton['text'] = ("Start")
startButton['font'] = (fontA, 40)
startButton.grid(row=4,column=0, columnspan=1, sticky=E+W, pady=25)
有人能帮我设置我的“那么你需要说明吗?”
谢谢。

创建标签、按钮或任何包含文本的内容时,您可以按如下方式定义字体和字体大小

from tkinter import *

root = Tk()
label1 = Label(root, text = 'Hello' font = ('Calibri', 12))

当“字体”功能的第一个参数是字体名称(只要您的计算机上安装了字体,它就可以工作),第二个参数是字体大小。

当创建标签或按钮或任何真正包含文本的内容时,您可以按以下方式定义字体和字体大小

from tkinter import *

root = Tk()
label1 = Label(root, text = 'Hello' font = ('Calibri', 12))

当“字体”功能的第一个参数是字体名称(只要您的计算机上安装了字体,它就会工作),第二个参数是字体大小。

您的操作方法与使用
titleBL
时相同。您介意举个例子吗?我试过了,但似乎不起作用。对不起,我对python非常陌生。您的操作方法与使用
titlebl
时相同。您介意举个例子吗?我试过了,但似乎不起作用。对不起,我是python新手。没关系,我发现了问题。谢谢你的帮助!没关系,我找到问题了。谢谢你的帮助!