Reputation: 7
I am trying to make a program in tkinter and I would like to reduce the text size and the only thing I can do is reduce the size of the button. I cut less important code. This is my code:
from tkinter import *
from tkinter import Tk
label1 = Label(okno, text="Kto wybił klan Uchiha?", font=30 )
label1.config(font=(30, 43, 'bold'))
label1.pack()
okno: Tk = Tk()
okno.geometry('700x850')
okno.title('Poziom Łatwy')
okno.mainloop()
Upvotes: 0
Views: 147
Reputation: 123541
You're not specifying the font correctly in your code. There are several ways to do it — here's some documentation.
Using the way that consists of using a tuple
containing the <font family>
, <size>
, and optionally a string of one or more <style modifiers>
in your code would make it look something like what's below.
Note that I extracted the font family name from the 'TkDefaultFont'
because I didn't want that to change. (Thanks to @Bryan Oakley for explaining to me the way to do that.)
from tkinter import *
from tkinter import Tk
import tkinter.font as tkfont
okno: Tk = Tk()
okno.geometry('700x850')
okno.title('Poziom Łatwy')
default_font_family = tkfont.nametofont('TkDefaultFont').cget('family')
label1 = Label(okno, text="Kto wybił klan Uchiha?", font=(default_font_family, 30))
label1.config(font=(default_font_family, 20, 'bold'))
label1.pack()
okno.mainloop()
Upvotes: 1