2

I'm creating a simple UI, my problem is that buttons are always white also if I change all their color properties...I'm new in Tkinter maybe I'm missing something.

This is the code, you can just copy and run:

import tkinter
tk = tkinter.Tk()


def browseFiles():
    print("Browsing...")


browseButton = tkinter.Button(
    tk, text="Browse files", command=browseFiles, fg='#03045e', bg='#caf0f8', background='#ef233c', activeforeground='blue').pack()

tk.mainloop()

This is a picture of result:enter image description here

MacOS version : 11.5.2 withPython 3.10.0rc2, tcl-tk 8.6.11_1 and when I run the code this is the warning :

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

Maybe I should downgrade to a python stable version ?

Finley Adams
  • 773
  • 1
  • 8
  • 20
  • Does [this](https://www.python.org/download/mac/tcltk/) help? – Random Davis Oct 06 '21 at 18:11
  • I already read this page, in fact I downloaded python3.10 from here. But I don't understand if I need to download something and what :S. Edited version with tlc-tk version – Finley Adams Oct 06 '21 at 18:18
  • Might as well try downgrading to stable and see if that helps. – Random Davis Oct 06 '21 at 18:33
  • But which one? 3.9 I don't know – Finley Adams Oct 06 '21 at 19:18
  • Well your version has `rc2`, I think [this page](https://www.python.org/downloads/macos/) should have the latest stable versions on it. Also you should make sure that you're actually using the 3.10 version of Python to run your scripts and not whatever was included with the OS. Also I'd suggest seeing if [this page](https://github.com/PySimpleGUI/PySimpleGUI/issues/1124) has any fixes that work for you. – Random Davis Oct 06 '21 at 19:28
  • [Here](https://stackoverflow.com/questions/58752385/tkinter-test-buttons-are-invisible-when-using-pipenv) is a related question with the same error message. The problem is similar too: the buttons are invisible. I suggest you read the accepted answer, and see if that works for you. – Sylvester Kruin Oct 06 '21 at 20:26
  • @SylvesterKruin I'm trying to figure it out but I don't have much experience and this seems to be an old problem... – Finley Adams Oct 06 '21 at 21:03

1 Answers1

4

Solved :

pip3 install tkmacosx

This will install some extensions that will fix the problem. Just one thing be sure to switch interpreter, maybe you're not using the right one. In my case it worked when I used this one enter image description here. Check where tkmacosx has been installed, you should use the same interpreter version I guess.

Finley Adams
  • 773
  • 1
  • 8
  • 20
  • Unfortunately, it didn't solve it for me. I've switched to Kivy as it's base install is pure python and doesn't have these issues with external libs. – Brian Booth Mar 10 '22 at 17:01