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

UI scales when toggling theme #11

Closed
yunkhngn opened this issue Dec 10, 2021 · 6 comments · Fixed by #46
Closed

UI scales when toggling theme #11

yunkhngn opened this issue Dec 10, 2021 · 6 comments · Fixed by #46

Comments

@yunkhngn
Copy link

I'm using Python and Tkinter for GUI. I've a function using switch and ttk for switching between light and dark mode:

def ThemeChanger():
    if screen.tk.call("ttk::style", "theme", "use") == "sun-valley-dark":
        # Set light theme
        screen.tk.call("set_theme", "light")
    else:
        # Set dark theme
        screen.tk.call("set_theme", "dark"

But when I clicked into the switch, all the UI automatically scales a litter bit:

image

image

It will scale larger if i use tabs or table in ttk Tkinter, and won't scale back when switch to light mode, it scales more and more when I clicked into theme switch button:

def change_theme():
    # NOTE: The theme's real name is sun-valley-<mode>
    if root.tk.call("ttk::style", "theme", "use") == "sun-valley-dark":
        # Set light theme
        root.tk.call("set_theme", "light")
    else:
        # Set dark theme
        root.tk.call("set_theme", "dark")

image
image
image
image
image

I don't know how to fix this. I would so appreciate if anyone can recommend me improving these. Thank you!

@rdbende
Copy link
Owner

rdbende commented Dec 10, 2021

Duplicate of #6
I just quickly done a diff light.tcl dark.tcl and I found nothing that might cause this issue. I remember I saw this issue with other ttk themes, but it's strange that it scales back when changing back to light theme.

@rdbende rdbende closed this as completed Dec 10, 2021
@stojshic
Copy link

I'm not sure that this is the same problem as in #6. I have the same problem in my app. I use tabs for different parts of UI, and if I'm in empty tab, it only scales once and stays the same, doesn't go bigger or smaller, but if I'm in the tab that has treeview, it gets bigger every time I use sv_ttk.toggle_theme(), can't figure out why... It doesn't shrink when returning to white theme like in #6, it just expands the UI for a bit...

@rdbende
Copy link
Owner

rdbende commented Jun 21, 2022

Probably related to rdbende/Azure-ttk-theme#20

@rdbende rdbende reopened this Jun 21, 2022
@rdbende rdbende changed the title Problem with Tkinter ttk theme in changing between light and dark (UI automatically scale) UI scales when toggling theme Jun 25, 2022
@rdbende rdbende pinned this issue Jul 13, 2022
@rdbende
Copy link
Owner

rdbende commented Jul 19, 2022

From the README:

When you change the theme, and your app has a treeview, the window resizes. This is a quite strange bug that applies to other ttk themes too.

@rdbende
Copy link
Owner

rdbende commented Aug 15, 2022

Probably related to rdbende/Azure-ttk-theme#20

Not related to it. This is a bug in Tk itself. rdbende/Azure-ttk-theme#40

@rdbende
Copy link
Owner

rdbende commented Aug 15, 2022

Bug reported in Tk core: https://core.tcl-lang.org/tk/tktview?name=bc602049ab

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

Successfully merging a pull request may close this issue.

3 participants