Svet GEoff
Svet GEoff

Reputation: 85

How to set font size in tkinter

Hope every one of us had great Christmas so far!

I need a bit of help with my font size in this code:

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()

I want the font size in the text area to be quite big so can be seen on my 3 inch raspberry pi display.

Script Running : enter image description here

Thank you in advance!

Upvotes: 0

Views: 231

Answers (1)

Diggy.
Diggy.

Reputation: 6944

Following what it says in Pmw's documentation, it seems as though you want to do the following:

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

References:

Upvotes: 1

Related Questions