【问题标题】:Python 3 Tkinter custom font in Label标签中的 Python 3 Tkinter 自定义字体
【发布时间】:2020-03-16 09:35:02
【问题描述】:

我想在我的标签中将自定义字体设置为 css 中的 @front-family ?

font = "C:/Users/Alex/Documents/myproject/Call of Ops Duty.otf"
mylabel = Label(main, text="This is a text", bg="black", fg="#fff", font=(font, 30))

mylabel = Label(main, text="This is a text", bg="black", fg="#fff", font=(Call of Ops Duty.otf, 30))

mylabel = Label(main, text="This is a text", bg="black", fg="#fff", font=("Call of Ops Duty", 30))

它不起作用;(

【问题讨论】:

  • 你的电脑里安装了这个字体吗?

标签: python-3.x tkinter font-family


【解决方案1】:

您不能以这些方式使用字体。 Tkinter 只能使用系统上安装的字体。

【讨论】:

    【解决方案2】:

    Tkinter 可以使用的唯一字体是预设字体:

    1. TkDefaultFont
      未另行指定的项目的默认值。
    2. TkTextFont
      用于条目小部件、列表框等。
    3. TkFixedFont
      一种标准的等宽字体。
    4. TkMenuFont
      用于菜单项的字体。
    5. TkHeadingFont
      列表和表格中列标题的字体。
    6. TkCaptionFont
      窗口和对话框标题栏的字体。
    7. TkSmallCaptionFont
      用于工具对话框的较小标题字体。
    8. TkIconFont
      图标标题的字体。
    9. TkTooltipFont
      工具提示字体。

    https://tkdocs.com/tutorial/fonts.html

    这意味着您无法将自己的字体导入标签

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 1970-01-01
      • 2019-01-22
      • 2011-09-06
      • 2013-02-24
      • 2017-04-17
      • 2022-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多