我在pythontkin中使用了一种新字体

2024-05-29 03:11:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经在我的计算机上安装了一个新字体,并且也安装在我的计算机上。 现在,我使用tkinter库在Python代码中使用它,但它不起作用。在

    self.master = master
    self.my_font = tkinter.font.Font(self.master, family="My Girl Is Retro Regular")
    self.master.grid_rowconfigure(0, weight=2)
    self.master.grid_columnconfigure(0, weight=1)
    self.playPhoto = PhotoImage(file='toppic.png')
    self.toppic = Label(self.master,image=self.playPhoto)
    self.toppic.grid(pady=(0,50))
    self.youtubeLinkLabel = Label(self.master, text="Paste the YouTube Link Below: ", font=("My Girl Is Retro Regular", 30),fg='red')
    self.youtubeLinkLabel.grid(pady=(0,20))
    self.youtubeEntryVar = StringVar()
    self.youtubeEntry = Entry(self.master, width=70, textvariable=self.youtubeEntryVar,font=("Agency FB", 25),fg='green')
    self.youtubeEntry.grid(pady=(0, 15),ipady=10)

    self.youtubeEntryError = Label(self.master, text="", font=("Concert One", 20))
    self.youtubeEntryError.grid(pady=(0, 8))

    # Asking where to save file label
    self.youtubeFileLocationLabel = Label(self.master, text="Choose Directory: ",font=("My Girl Is Retro Regular", 60))
    self.youtubeFileLocationLabel.grid()

    self.youtubeFileLocationEntry = Button(self.master, text="Directory", command=self.openDirectory)
    self.youtubeFileLocationEntry.grid(pady=(10, 3))

    # Entry label if user don`t choose directory
    # openDirectory func
    self.fileLocationLabelError = Label(self.master, text="", font=("My Girl Is Retro Regular", 20))
    self.fileLocationLabelError.grid()

    # What to download MP3 or MP4 label
    self.youtubeChooseLabel = Label(self.master, text="Please choose what to download: ",
                                        font=("My Girl Is Retro Regular", 30))
    self.youtubeChooseLabel.grid()

我已经在谷歌上搜索过了,但找不到


Tags: totextselfmasterismylabelgrid
1条回答
网友
1楼 · 发布于 2024-05-29 03:11:53

您调用的字体名称不正确,您会注意到它产生了意外的字体。如果您在windows上,打开ttf文件,名称就会在那里。以下是截图:

enter image description here

在上面的屏幕截图中,字体名是Alien League。您可以尝试将My Girl Is Retro Regular替换为Comic Sans MS,这是一种内置的Windows字体。它会起作用的。
我找到了你使用的字体的正确名称。它的My Girl Is Retro。在

相关问题 更多 >

    热门问题