Button problem, got there eventually

I was learning how to use Tkinkter. I am incredibly new at this and I was trying to change the colour of a button.

My code was:

button = Button(box, text = "Enter", command = printbox, padx=10, pady=10, bg="blue", fg="blue")
button.grid(row=2, column=1)

But weirdly the background of my button isnt blue, only the text.

Hello, @Notem, and welcome to Python!

You aren’t stupid, you are just new to this, and learning.

I have not used Tkinter much myself. But in a situation like this, my first step is to look at the documentation to check if I have done it right. Can you post a link to the documentation for Button() in the Tkinter documentation? Then we can read it together, and see if we can figure it out.

Best regards,
—Jim

The closest thing I could find was this:https://docs.python.org/3/library/tkinter.ttk.html#ttk-widgets

That’s great!

That’s a page within the Python docs about tkinter. Have you had a look at the top page of that section: tkinter — Python interface to Tcl/Tk? Reading that page, up until “Architecture”, will give you some orientation.

The overview suggests running python -m tkinter, “so you can read the Tcl/Tk documentation specific to that version.” Have you tried that? What tkinter version did it show? Also, what Python version are you using?

The overview points to TkDocs. TkDocs includes a Tutorial. Have you tried working through the tutorial?

Following some links, I got to the Ttk documentation for button at ttk::button manual page - Tk Themed Widget . It says that the options for colour styling are foreground and background, not fg and bg. Maybe try those attribute names instead?

Best regards,
—Jim DeLaHunt

ok wait i figured it out:
my python was acting weird so i had to install tkmaxosx

import tkmacosx
Button = tkmacosx.Button
button = Button(window, text="Enter", command = printbox, padx=10, pady=10, background="red", foreground="blue")

i now have a god awful looking button :smiley:

Yay! Good for you.

Now, re-edit the topic title to withdraw the false claim that you are stupid. You are clever, you are persistent, and you are successful!