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

CTkOptionMenu & CTkComboBox throw error during display scale change after being destroyed #2584

Open
Franzyd opened this issue Sep 19, 2024 · 2 comments

Comments

@Franzyd
Copy link

Franzyd commented Sep 19, 2024

Tested on Windows 10
The two dropdown menu widgets, CTkOptionMenu and CTkComboBox throw a TcLError: invalid command name when the window's scale changes after being destroyed. Tested scenarios are changing the display scale in Windows settings and moving it to another monitor with a different display scale.

import customtkinter

app = customtkinter.CTk()
app.geometry("400x150")

options = customtkinter.CTkOptionMenu(app, values=["1", "2", "3"])
options.pack() //layout manager is irrelevant

delete = customtkinter.CTkButton(app, text="Delete", command= lambda: options.destroy())
delete.pack()

app.mainloop()

Clicking the button to destroy the dropdown widget and then changing the display scale throws:

File "C:\Python312\Lib\tkinter\__init__.py", line 1962, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\tkinter\__init__.py", line 861, in callit
    func(*args)
  File "C:\Python312\Lib\site-packages\customtkinter\windows\widgets\scaling\scaling_tracker.py", line 187, in check_dpi_scaling
    cls.update_scaling_callbacks_for_window(window)
  File "C:\Python312\Lib\site-packages\customtkinter\windows\widgets\scaling\scaling_tracker.py", line 64, in update_scaling_callbacks_for_window    
  File "C:\Python312\Lib\site-packages\customtkinter\windows\widgets\core_widget_classes\dropdown_menu.py", line 193, in _set_scaling
    self._configure_menu_for_platforms()
  File "C:\Python312\Lib\site-packages\customtkinter\windows\widgets\core_widget_classes\dropdown_menu.py", line 66, in _configure_menu_for_platforms    super().configure(tearoff=False,
  File "C:\Python312\Lib\tkinter\__init__.py", line 1716, in configure
    return self._configure('configure', cnf, kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\tkinter\__init__.py", line 1706, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".!ctkcombobox.!dropdownmenu"

After that the window is still interactable but semitransparent and doesn't rescale anymore:
image

@dipeshSam
Copy link

Did you try any workaround to fix this?

@Franzyd
Copy link
Author

Franzyd commented Oct 1, 2024

@dipeshSam unfortunately I haven't

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