CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

AttributeError: '_tkinter.tkapp' object has no attribute 'block_update_dimensions_event'

Open Nianzu opened this issue 2 years ago • 6 comments

I have an application that opens multiple windows, and when running on Windows 10 with Python3.9, opening a second window causes this error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 814, in callit
    func(*args)
  File "C:\Users\Zico\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\customtkinter\windows\widgets\scaling\scaling_tracker.py", line 186, in check_dpi_scaling
    window.block_update_dimensions_event()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 2354, in __getattr__
    return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'block_update_dimensions_event'

I've tried researching this, but I can't find anything. To my knowledge, I'm not missing any packages. I've uninstalled and reinstalled python, as well as tried this on multiple computers.

Nianzu avatar Oct 06 '23 16:10 Nianzu

By commenting out lines 186 and 188 in C:\Users\Zico\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\customtkinter\windows\widgets\scaling\scaling_tracker.py as shown below, the application works as expected.

    @classmethod
    def check_dpi_scaling(cls):
        new_scaling_detected = False

        # check for every window if scaling value changed
        for window in cls.window_widgets_dict:
            if window.winfo_exists() and not window.state() == "iconic":
                current_dpi_scaling_value = cls.get_window_dpi_scaling(window)
                if current_dpi_scaling_value != cls.window_dpi_scaling_dict[window]:
                    cls.window_dpi_scaling_dict[window] = current_dpi_scaling_value

                    if sys.platform.startswith("win"):
                        window.attributes("-alpha", 0.15)

                    # window.block_update_dimensions_event()
                    cls.update_scaling_callbacks_for_window(window)
                    # window.unblock_update_dimensions_event()

                    if sys.platform.startswith("win"):
                        window.attributes("-alpha", 1)

                    new_scaling_detected = True

Nianzu avatar Oct 06 '23 16:10 Nianzu

Sorry to ping again, is there any acknowledgment that this is an issue? I assume this is not intended behavior. Does anyone know what those lines in my comment do under normal circumstances? Perhaps they can be removed entirely? As I mentioned, there does not seem to be adverse effects from commenting out those lines.

Nianzu avatar Oct 13 '23 18:10 Nianzu

@TomSchimansky , I face the same issue with CustomTkinter v5.2.0. Is there a solution or work around to this issue ? I tried the workaround as suggested by @Nianzu , but that messes up the overall UI size/scaling

PyCodeGeek avatar Nov 09 '23 01:11 PyCodeGeek

Could you provide replication steps? I'd like for my PR to be something stable, so I'll work on it.

Nianzu avatar Nov 09 '23 17:11 Nianzu

I'm getting a similar issue, did anyone figure out a work around for it?

Amchanie avatar Mar 15 '24 15:03 Amchanie

@Nianzu, @Amchanie

  • Tried updating customtkinter to the latest version 5.2.2 using pip?

  • Could you please provide a sample code which produce this error?

Regards.

dipeshSam avatar Mar 25 '24 03:03 dipeshSam