frame.config(background="black") returns the error unknown option "-background" because this is a ttk.Frame, not a tkinter.Frame and the background of a ttk.Frame is changed using a ttk.Style (see example below).
lab.config(background="black") gives the error 'NoneType' object has no attribute 'config' because you did lab = tk.Label(...).grid(...) and grid returns None so lab is None, not a Label.
root.config(background="black") does nothing because the widgets fill the window so you cannot see the background like naknak12 explained.
Here is an example using ttk widgets:
import tkinter from tkinter import ttk root = tkinter.Tk() root.configure(background='black') # style configuration style = ttk.Style(root) style.configure('TLabel', background='black', foreground='white') style.configure('TFrame', background='black') frame = ttk.Frame(root) frame.grid(column=0, row=0) ttk.Button(frame, text="Open file", command=None).grid(column=0, row=1) lab = ttk.Label(frame, text="test test test test test test ") lab.grid(column=0, row=2) root.mainloop()
And an example without ttk:
import tkinter root = tkinter.Tk() frame = tkinter.Frame(root) frame.grid(column=0, row=0) tkinter.Button(frame, text="Open file", command=None).grid(column=0, row=1 ) lab = tkinter.Label(frame, text="test test test test test test ") lab.grid(column=0, row=2) root.configure(background='black') lab.configure(background='black', foreground='white') frame.configure(background='black') root.mainloop()
tk.Label().grid()tolab. You have to assign the return value oftk.Label()tolaband call.grid()after the assignment