I am a beginner with python and Tkinter and I want to make custom buttons that look better. How do I make Tkinter buttons utilize custom backgrounds and text colors in python?
CodePudding user response:
Making colored buttons with Tkinter isn't hard, you just have to add some arguments while defining the button.
from tkinter import *
# Define the Window
root = Tk()
# Add a Title to The Window
root.title('Colored Button')
# Geometry of window; width by length in pixels
root.geometry('300x200')
# Define the Button; fg is the foreground, bg is the background.
colored_button = Button(root, fg='White', bg='Black', text = 'Click Me')
# Pack the Button
colored_button.pack()
# Run the TKinter loop
root.mainloop()