如何使我的字符串的一部分与其余部分的字体和大小不同

How to make a section of my string a different font and size then the rest

我正在尝试使字母 ahc 成为 courier 的粗体版本,同时将字符串的其余部分保持为常规 courier。我正在谈论的代码行在 upper_label 变量中。

现在在tkinter界面上,显示

                 A Computer Science Glossary
                            by
                            ahc

但我想让它说

                A Computer Science Glossary
                            by
                            AHC <----- "i want that o be in bold"

import tkinter as tk
from tkinter.font import Font



root = tk.Tk()

HEIGHT = 700
WIDTH=600
#my_font=tk.Font("courie",weight="bold")


canvas = tk.Canvas(root,height = HEIGHT, width = WIDTH)
canvas.pack()

upper_frame = tk.Frame(canvas, bg="black")
upper_frame.place(relx=0, rely=0,relwidth=3,relheight=0.8,anchor="center")



upper_label= tk.Label(upper_frame,text="A Computer Science Glossary\nby\nahc",font="courie",fg="white", bg="black")
upper_label.place(relx=0.6,rely=0.5)

lower_frame = tk.Frame(root, bg="black")
lower_frame.place(relx=1,rely=1,relwidth=2,relheight=0.3, anchor="center")

bottom_label=tk.Label(lower_frame,text="click here to exit:", fg="white", bg="black")
bottom_label.place(relx=0,rely=0)

bottom_button = tk.Button(lower_frame, text= "Exit")
bottom_button.place(relx=0, rely=0.1,width=100)

root.mainloop()

创建一个新标签并将其放在非粗体标签下方:

upper_label= tk.Label(upper_frame,text="A Computer Science Glossary\nby",font="courie",fg="white", bg="black")
upper_label.place(relx=0.6,rely=0.5)
tk.Label(upper_frame,text="ahc",font="courie 16 bold",fg="white", bg="black").place(relx=0.66,rely=0.6)