0

I have this problem that tkinter wont let me change the bg color. I tried using the normal "white" or "blue", etc. I tried Hex-Code and RGB-Code. Nothing works and I am going crazy. The color also does not change when using widgets, so it is alwasy a dark screen, but I creates the widgets since I can see the cursor change or button show up when I am using a picture.

Even old tkinter programs wont work anymore since the screen stays black.

import tkinter as tk

window = tk.Tk()
window.config(bg="white")
window.mainloop()

So does anyone know what I am doing wrong or is it a problem with the IDE? I am going crazy here.

z3nox
  • 15
  • 1
  • 5
  • Out of curiosity, which OS / IDE are you using? – JRiggles Nov 30 '22 at 18:29
  • I am using MacOs – z3nox Nov 30 '22 at 18:33
  • I may have a solution [here](https://stackoverflow.com/a/73186351/8512262) in that case. The version of tkinter that ships with the system is outdated, which is why you're seeing a black screen. Let me know if that helps! FYI, if my linked solution does work out, I'll mark this question as a duplicate so other folks hopefully get pointed in the right direction. Just wanted to give you a heads-up! – JRiggles Nov 30 '22 at 18:34
  • It finally worked. I have no idea what happened since it did work in the past, but it works again after some trying. Thank you! – z3nox Nov 30 '22 at 18:52
  • Glad to hear it! Are you good with me closing this question as a duplicate? – JRiggles Nov 30 '22 at 18:54
  • 2
    Does this answer your question? [Tkinter on mac shows up as a black screen](https://stackoverflow.com/questions/73056296/tkinter-on-mac-shows-up-as-a-black-screen) – JRiggles Nov 30 '22 at 19:31

1 Answers1

0

Mac OS used keyword highlightbackground.

Change this:

window.config(bg="white")

to:

window.config(highlightbackground="white")
toyota Supra
  • 3,181
  • 4
  • 15
  • 19