Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme/style not applied to Toplevel Widget #128

Open
Aesonus opened this issue Jan 29, 2024 · 2 comments
Open

Theme/style not applied to Toplevel Widget #128

Aesonus opened this issue Jan 29, 2024 · 2 comments

Comments

@Aesonus
Copy link

Aesonus commented Jan 29, 2024

After updating to version 2.6 it appears that the theme is no longer being applied to Toplevel widgets.

Using the following code:

import tkinter as tk
from tkinter import ttk

import sv_ttk

root = tk.Tk()
sv_ttk.use_light_theme()

toplevel = tk.Toplevel(root)
toplevel.title("Test Toplevel")
ttk.Label(toplevel, text="Hello, world!").pack()
ttk.Button(toplevel, text="Close", command=root.quit).pack()
toplevel.protocol("WM_DELETE_WINDOW", root.quit)

root.withdraw()
root.mainloop()

On version 2.6 it looks like this (wrong):
bad-window

On version 2.5.5 (correct):
good-window

This is on a Windows 11 system. I have not tested it yet on any other OS, so I am not sure if this is a problem for them too, or just Windows 11.

EDIT:
I did test the Tk widget and the styles are applied correctly to widgets in it.

EDIT 2:
It also looks like if there is a ttk widget added to the Tk widget, then the TopLevel displays correctly:

@littlewhitecloud
Copy link
Contributor

littlewhitecloud commented Jan 30, 2024

It was caused by #113, I just tested it.
That's strange, I test a lot but can not fix it.

@Aesonus
Copy link
Author

Aesonus commented Jan 30, 2024

I think it may have something to do with the event propogation. If I do:

root.after(10, sv_ttk.use_light_theme)

Then everything works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants