Cómo fijar el color de fondo de Tkinter
El método de clase del widget de Tkinter configure y el atributo bg o backgroud pueden ser usados para establecer el color de fondo del widget/window de Tkinter.
Método configure(background= )
try:
import Tkinter as tk
except:
import tkinter as tk
app = tk.Tk()
app.title("configure method")
app.geometry("300x200")
app.configure(bg="red")
app.mainloop()
Aquí,
app.configure(bg='red') configura el color de fondo de app para que sea red. También puedes usar background en lugar de bg.
app.configure(background='red')

Atributo bg o background
background o bg es un atributo en la mayoría de los widgets de Tkinter, y puede ser usado para establecer el color de fondo directamente.
try:
import Tkinter as tk
except:
import tkinter as tk
app = tk.Tk()
app.title("bg attribute")
app.geometry("300x200")
app["bg"] = "blue"
app.mainloop()

Código de color Tkinter
Puedes especificar el color con los nombres conocidos como red, blue o green como se muestra arriba, y también puedes especificarlo vía RGB como códigos de color hexadecimal en HTML, por ejemplo, #49A o #0059b3.
try:
import Tkinter as tk
except:
import tkinter as tk
app = tk.Tk()
app.title("bg attribute")
app.geometry("300x200")
app["bg"] = "#0059b3"
app.mainloop()

try:
import Tkinter as tk
except:
import tkinter as tk
app = tk.Tk()
app.title("bg attribute")
app.geometry("300x200")
app["bg"] = "#49A"
app.mainloop()

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.
LinkedIn Facebook