Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Tkinter not support MacOS Mojave Dark Mode

I have a problem with the support of Dark Mode on MacOS in python Tkinter. I used python 3.6 with ActiveTlc 8.5 and the Dark Mode works fine, the window titlebar was dark, it's fine for me... but there were some problems with the <MouseWheel> support, then I upgraded python to 3.7.1 and the version of tlc is updated to 8.6.

But now the Dark Mode didn't work, and it's strange, why this is happening?

This is an example code:

from tkinter import *

if __name__ == '__main__':
    root = Tk()
    hero_text = Label(root, fg='white', bg='black', text='HERO TEXT')
    hero_text.grid(row=0, sticky=N+W)
    print(root.tk.exprstring('$tcl_library'))
    print(root.tk.exprstring('$tk_library'))
    root.mainloop()
like image 900
Benedetto Abbenanti Avatar asked Apr 10 '26 18:04

Benedetto Abbenanti


1 Answers

I also faced this kind of problem, I think you should try this

from tkinter import *

if __name__ == '__main__':
       root = Tk()
       root.configure(bg="black")
       hero_text = Label(root, fg='white', bg='black', text='HERO TEXT')
       hero_text.grid(row=0, sticky=N+W)
       print(root.tk.exprstring('$tcl_library'))
       print(root.tk.exprstring('$tk_library'))
       root.mainloop()
like image 156
Aninet Avatar answered Apr 13 '26 08:04

Aninet