更改 tkinter 菜单的字体

Change font of tkinter menu

我一直在努力更改下面 class 菜单中 'File' 按钮的字体。

self.config(font=self.font) 不起作用,add_cascade(font=self.font)

也不起作用

我正在使用 Windows10.

非常感谢任何帮助!

from tkinter import *
import sys

class DatabaseMenu(Menu):
    """Menu for configuring database"""

    def __init__(self, parent, callbacks, **kwargs):
        super().__init__(parent)
        self.callbacks = callbacks
        self.font = ("Calibri", 15)
        self.config(font=self.font)
        self._build_menu()


    def _build_menu(self):

        self.file_menu = Menu(self, tearoff=False)
        self.file_menu.add_command(
            label="Change database structure",
            command=self.callbacks['file->change_database_structure'],
            font=self.font
            )

        self.add_cascade(label=' File ', menu=self.file_menu, font=self.font)

if __name__ == '__main__':
    root = Tk()
    menu = DatabaseMenu(root, {'file->change_database_structure':sys.exit})
    root.config(menu=menu)
    root.mainloop()

您不能使用 tkinter 更改菜单栏或其菜单的字体。这些菜单由底层 OS 呈现,而不是由 tkinter 呈现。