0

I want to Increase the Label Font Size of my GUI. I tried the way I attached below. But it that raises an error. What I tried so far is the code below. The error is

Traceback (most recent call last):
  File "C:/Users/kobinath/PycharmProjects/pythonProject4/ex.py", line 123, in <module>
    style = root.Style()
  File "C:\Users\kobinath\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2345, in __getattr__
    return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'Style**
root = Tk()
style = root.Style()
style.configure(
   "BW.TLabel",
   foreground="black",
   background="white",
   font="Helvetica",
   fontsize=12
   )
    
tk.Label(root, text="Student ID",style="BW.TLabel").place(x=400, y=5)
Aven Desta
  • 2,114
  • 12
  • 27
  • if you want to use Style object import tkk. `from tkinter import tkk ; style = ttk.Style()` – Purya Jan 06 '21 at 14:56

1 Answers1

0

You can use the fg, bg, and font parameters in the tkinter label as seen in the following code:

import tkinter as tk

root = tk.Tk()

tk.Label(root, text="Student ID", fg= "black", bg="white", font=("Helvetica",12)).place(x=400, y=5)

root.mainloop()
DapperDuck
  • 2,728
  • 1
  • 9
  • 21