Azure-ttk-theme icon indicating copy to clipboard operation
Azure-ttk-theme copied to clipboard

filedialog window has white text on white background (for dark mode)

Open OleMussmann opened this issue 2 years ago • 7 comments

The tkinter filedialog pop-up has a white background, even when styled in the dark Azure theme. This makes the white filename-texts unreadable.

OleMussmann avatar May 12 '22 21:05 OleMussmann

I assume this happens on Linux, though I wasn't able to reproduce it. Could you please attach some example code?

rdbende avatar May 30 '22 15:05 rdbende

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.

bug_35

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()

OleMussmann avatar May 30 '22 16:05 OleMussmann

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 🥴

rdbende avatar May 30 '22 16:05 rdbende

Note for myself: https://stackoverflow.com/questions/53655418/tkfiledialog-asksaveasfile-text-color-font#comment109368049_53656679

Edit: I can't get this to work

rdbende avatar Nov 01 '22 10:11 rdbende

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

pabloo87 avatar May 09 '23 12:05 pabloo87

Turns out it's some kind of canvas thingy.

rdbende avatar Jul 03 '23 05:07 rdbende

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.

rdbende avatar Jul 03 '23 05:07 rdbende