Changing Color Of Buttons In Tkinter Works On Windows But Not Mac Osx
Edit: I tried it on Windows and it works, I guess it is a OSX bug? The following code does not work for some reason and the button stays white z = Button(frame, text='Nothing Sched
Solution 1:
for python3, try
pip3 install tkmacosx
Then it should be work with this:
from tkmacosx import Button as button
B1 = button(frame, text = 'Hello!', bg = 'black', fg = 'white',command = testing)
Solution 2:
In this page of the tcl/tk wiki are listed some problems related to Mac and the color of labels and buttons's backgrounds. For example:
...
The Mac OS X background color should not be white, it should be #ececec. Since winfo rgb does not work properly on the mac colors, this makes it difficult to get the proper default color.
... etc.
Saludos!,
Solution 3:
I meet the same problem on osx 10.14.3, then I replace with the ttk button, and it works!
from tkinter importttkb1= ttk.Button(root, text="start", width=15, command=begin)
Solution 4:
Use tkmacosx Library it allows you to change the button color in MacOSX.
Install
pip install tkmacosx
Example
from tkinter import *
from tkmacosx import Button
root = Tk()
root.geometry("200x200")
B1 = Button(root, text='Button', bg='red')
B1.grid(row=0, column=1)
root.mainloop()
Post a Comment for "Changing Color Of Buttons In Tkinter Works On Windows But Not Mac Osx"