I\'m trying to achieve a black file dialog box (Mac OS dark mode). I\'m using Tkinter filedialog module (import tkinter.filedialog
).
I'm not a GUI developer, but I'm pretty sure OSX won't let you change the colour of entities such as a dialog window...
If it helps, I ran your code and got the following:
I am using OSX Dark Mode though...
Possible issues that won't let you have proper Dark Mode support on Tkinter GUI. All of these were are on my Mac it could differ in every system.
By default, the dark mode doesn't apply to every application like some apps that are third parties and from untrusted developers. We can still achieve Dark Mode to those apps, but not every app will work properly maybe that's why it is not an option in the setting.
If you’re not confident in using the command line you probably should not do this.
Enable the Dark Mode and then run this command in terminal:
defaults write -g NSRequiresAquaSystemAppearance -bool No
Note: "Yes" means disable to all windows and "No" means enable to all.
After running the command log out and log back in to notice the changes.
If you want to revert back to default settings, simply delete the NSRequiresAquaSystemAppearance
setting with the following command.
defaults delete -g NSRequiresAquaSystemAppearance
If you use Anaconda then you just need to perform 1st Step to get the Dark Mode on all apps then update Tcl/Tk to 8.6.9 from the command line. (More Details)
conda install -c conda-forge tk
conda install -c conda-forge/label/gcc7 tk
conda install -c conda-forge/label/broken tk
conda install -c conda-forge/label/cf201901 tk
Results
UPDATE:
Anaconda has updated Tcl/Tk to 8.6.10 and also added one new command which supports different appearance modes of macOS (dark, light), which means changing any mode will change the background color of the window and widgets as well but it is a bit glitchy. And also we have to pass foreground = 'black
to see the text of Button
and for some other widgets as well.
conda install -c conda-forge/label/cf202003 tk
After solving the first issue you will get Dark Mode on Tkinter but a black screen on the Tkinter window if you have Tcl/Tk 8.6.8.
Sample Image
This problem has fixed in Tcl/Tk 8.6.9 but as python.org has not updated it and also supplies their own private copies of Tcl/Tk 8.6.8. They do not look for or use any third-party or system copies of Tcl/Tk(More Details). So it'll be a waste of time if you thinking to install it from third parties.
I tested Python 3.7.2rc1 which is built-in Tcl/Tk 8.6.9 and it works well with Mojave Dark Mode but due to some regressions found in Tk 8.6.9.1, they reverted the released python.org 3.7.2 macOS installers back to Tcl/Tk 8.6.8.
Sample Image