【问题标题】:How to set font size in tkinter如何在 tkinter 中设置字体大小
【发布时间】:2020-12-28 22:25:47
【问题描述】:

希望到目前为止我们每个人都度过了美好的圣诞节!

在这段代码中我需要一些关于我的字体大小的帮助:

import Pmw
from tkinter import * 
import tkinter.font 

root = Tk()
root.title("Dashboard") 
root.attributes('-zoomed', True)

filename = "SMS.txt"
        
top = Frame(root); top.pack(side='top')
text = Pmw.ScrolledText(top,
       borderframe=5, 
       vscrollmode='dynamic', 
       hscrollmode='dynamic',
       labelpos='n', 
       label_text='Todays Data %s' % filename,
       text_width=120, 
       text_height=35,
       text_wrap='none',
       text_padx=14,
       text_pady=14,
       )
text.pack()
text.insert('end', open(filename,'r').read())

root.mainloop()

我希望文本区域的字体很大,以便在我的 3 英寸树莓派显示器上看到。

脚本运行:

提前谢谢你!

【问题讨论】:

  • 这是有文档的,并且可能在几乎每个 tkinter 教程中都提到过。你做过研究吗?为什么需要 Stackoverflow 的帮助?
  • tkinter有自己的ScrolledText时,为什么还要使用Pmw

标签: python-3.x user-interface tkinter


【解决方案1】:

按照 Pmw 文档中的说明,您似乎想要执行以下操作:

font_size = 20  # Edit this value here
my_font = Pmw.logicalfont("Fixed", font_size)
text = Pmw.ScrolledText(text_font=my_font)  # Along with the other kwargs you'd need

参考资料:

【讨论】:

    猜你喜欢
    • 2013-06-26
    • 2015-01-16
    • 2010-09-22
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多