簡體   English   中英

如何在 tkinter 中設置字體大小

[英]How to set font size in tkinter

希望到目前為止我們每個人都度過了美好的聖誕節!

在這段代碼中,我需要一些關於我的字體大小的幫助:

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 英寸樹莓派顯示器上看到。

腳本運行: 在此處輸入圖像描述

先感謝您!

按照 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

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM