pythonmacostkinter

How to Fix Python Script Tkinter Buttons/Checkbox Appearing Unfocused on MACOS


I have a script when I run it through idle shell the tkinter Buttons/Checkbox look as I would expect, however when I run the same script through the terminal the Buttons/Checkbox appear as though they are unfocused.

Ran through Terminal Ran through Idle

Update: I was able to get it to show correctly running from the terminal by changing my shebang line from #!/usr/bin/env python3 to #!/usr/bin/env python3.11

I will have to try this on a couple MACs, but not sure if this will for any that don't have python 3.11

Update2: I was finally able to get back to this and was able to resolve the issue, for some reason the terminal was using python 3.9 and idle shell was using 3.11, after reinstalling 3.11 it works as I wanted it to in the first place

My code was something like this:

#!/usr/bin/env python3
import tkinter as tk

root = tk.Tk()
root.title("GUI")
root.geometry("300x150")

my_button = tk.Button(root, text="Click Me")
my_button.pack()

root.mainloop()

Solution

  • The terminal was using python 3.9 and idle shell was using 3.11, after reinstalling 3.11 it works as I wanted it to in the first place.

    In the terminal I just did python3 -V and this showed what version the terminal was using and I compared that against idle shell