Azure-ttk-theme
Azure-ttk-theme copied to clipboard
filedialog window has white text on white background (for dark mode)
The tkinter filedialog pop-up has a white background, even when styled in the dark Azure theme. This makes the white filename-texts unreadable.
I assume this happens on Linux, though I wasn't able to reproduce it. Could you please attach some example code?
Thanks for the reply, @rdbende . I should have included more information to begin with.
- Tested Python versions: 3.6.9, 3.10.3
- Host system: Ubuntu 20.04
The askdirectory
dialog has a white background. The font is white or invisible, rendering the text unreadable. Once selected or clicked on, the text changes to black (and staying black!), making it readable. See screenshot attached.
import tkinter as tk
from tkinter import ttk, filedialog
class App(ttk.Frame):
def __init__(self, parent):
ttk.Frame.__init__(self)
self.widgets_frame = ttk.Frame(self)
self.widgets_frame.grid()
self.button = ttk.Button(self.widgets_frame, text="Open Folder",
command=filedialog.askdirectory)
self.button.grid(row=0, column=0, padx=5, pady=10, sticky="nsew")
if __name__ == "__main__":
root = tk.Tk()
root.tk.call("source", "azure.tcl")
root.tk.call("set_theme", "dark")
app = App(root)
app.pack(fill="both", expand=True)
root.mainloop()
Ohh yess, now I see. Tho it's really strange. Why do do that item remain black when unselected? 🤔
Now I don't even know what that widget is. Kinda looks like a Treeview
, wrapped into an Entry, but then why it isn't themed?
Now I'm a bit confused, lol 🥴
Note for myself: https://stackoverflow.com/questions/53655418/tkfiledialog-asksaveasfile-text-color-font#comment109368049_53656679
Edit: I can't get this to work
I found this workaround:
I commented in azure.tcl the next block
#tk_setPalette background [ttk::style lookup . -background] \ #foreground [ttk::style lookup . -foreground] \ #highlightColor [ttk::style lookup . -focuscolor] \ #selectBackground [ttk::style lookup . -selectbackground] \ #selectForeground [ttk::style lookup . -selectforeground] \ #activeBackground [ttk::style lookup . -selectbackground] \ #activeForeground [ttk::style lookup . -selectforeground]
Lines 35-41
Turns out it's some kind of canvas thingy.
I could hack the canvas to make the background dark, but then it wouldn't work after an item is selected. Probably it's gonna be a ticket in Tk's source repo.