rdbende / Sun-Valley-ttk-theme

A gorgeous theme for Tkinter/ttk, based on the Sun Valley visual style ✨
https://pypi.org/project/sv-ttk
MIT License
1.97k stars 112 forks source link

TclError: unknown option "-troughcolor" #52

Closed littlewhitecloud closed 1 year ago

littlewhitecloud commented 2 years ago

I was programming a project. I did:

self.tk.call("source", self.path)
self.tk.call("set_theme", "light")

And I made a function like this:

def dark_mode(self, sync = True):
    """Turn Program into Dark Mode"""
    if sync:
    self.tk.call("set_theme", "dark")

    DWMWA_USE_IMMERSIVE_DARK_MODE = 20
    set_self_attribute = windll.dwmapi.DwmSetWindowAttribute
    get_parent = windll.user32.GetParent
    hwnd = get_parent(self.winfo_id())
    rendering_policy = DWMWA_USE_IMMERSIVE_DARK_MODE
    value = c_int(2)
    set_self_attribute(hwnd, rendering_policy, byref(value), sizeof(value))
    self["background"] = "black"

I want to make the program turn into dark mode, and I want theme into dark mode too. But I get a error, it is:

_tkinter.TclError: unknown option "-troughcolor"

How can I change theme when it has already been loaded?

littlewhitecloud commented 2 years ago

image

^ |

rdbende commented 2 years ago

What Tcl and Tk version are you using?

print(f"Tcl: {tkinter.TclVersion}")
print(f"Tk: {tkinter.TkVersion}")
littlewhitecloud commented 2 years ago

image

littlewhitecloud commented 2 years ago

Tcl & Tk Both 8.6

rdbende commented 2 years ago

This is really strange. I cannot reproduce it, and I have never seen anybody with this error. Does the issue still persist if you use sv_ttk instead of this old and discouraged .tk.call() method?

littlewhitecloud commented 2 years ago

okay, i will use sv_ttk

littlewhitecloud commented 2 years ago

thx

littlewhitecloud commented 2 years ago

image The problem arises again... And i use sv_ttk...

littlewhitecloud commented 2 years ago

script is in my github:github.com/sadjok/Editor

sumeshir26 commented 2 years ago

It looks like you dont use sv_ttk: image Can you try that?

littlewhitecloud commented 2 years ago

i just move sv_ttk to my asset folder... image

littlewhitecloud commented 2 years ago

asset folder...: image

littlewhitecloud commented 2 years ago

sv.tcl & theme.py & theme folder

sumeshir26 commented 2 years ago

Try installing sv_ttk using pip install sv-ttk in your terminal, and then import sv_ttk in your code, and then sv_ttk.use_light_theme() to start sv_ttk. Hope this helps.

littlewhitecloud commented 1 year ago

image ...It.emm.well.i just want to give up now :(

littlewhitecloud commented 1 year ago

Or, how to make a function like sv_ttk changing the theme for the window every time when I change the theme in the Settings?(Almost sync?)

sumeshir26 commented 1 year ago

Well maybe require a app restart to chage the theme... sorry, i cant tkink about any other solutuon :(

littlewhitecloud commented 1 year ago

Thanks for the answer, sorry for my interruption to you......

littlewhitecloud commented 1 year ago

Hope who can solve it.... However, i am tired of it, i tried too many times too...... Each time, the same wrong shows.....