Tkinter buttons not showing text on my mac, although code works on others computers

Viewed 4621

I have a functioning code that will not show text on the buttons unless I click and hold the button. When releasing the button's text becomes blank again. I have tried solving this on other forums and

please note: THERE IS NOTHING WRONG WITH THE CODE ITSELF.

There is some sort of issue with how my laptop is running the code. I've tried reinstalling python3.7 as well as tcl-tk. I really don't know what else to do.

3 Answers

Here is solution to add this line from tkinter import ttk.

and than use ttk. everywhere you plain to use Button, Label, Entry, etc.:

ttk.Button(text="Login", width="30", command = login).pack()

Here is code so you can try it.

def main_screen():
  from tkinter import ttk

  global screen
  screen = Tk()

  screen.geometry("500x500")
  screen.title("4rManager")

  Label(text="Login/Register", font=("Calibri", 13)).pack()
  ttk.Label(text="").pack()
  ttk.Button(text="Login").pack()
  ttk.Label(text="").pack()
  ttk.Button(text="Register").pack()

  screen.mainloop()

main_screen()

Hope I helped.

The reason for that might be how you installed the python. For some, if you installed from hombrew, it doesn't work.

So, try removing python in hombrew. Download and install it from the actual website.

Updating doesn't work for everyone, I've read several posts of those for whom it didn't, and it didn't for me.

But since resizing the window works, there must be something that the tk instance does when resizing that makes everything appear again.

So you might check what happens there, and use that if your program detects if the OS is Mojave. Obviously this is not production worthy and only a fix for your own local projects or maybe some course project, but at least it's something.

Related