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

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

Open
Nianzu opened this issue Oct 6, 2023 · 6 comments · May be fixed by #2594
Open

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

Nianzu opened this issue Oct 6, 2023 · 6 comments · May be fixed by #2594

Comments

@Nianzu
Copy link

Nianzu commented Oct 6, 2023

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
Copy link
Author

Nianzu commented Oct 6, 2023

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
Copy link
Author

Nianzu commented Oct 13, 2023

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.

@PyCodeGeek
Copy link

@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

@Nianzu
Copy link
Author

Nianzu commented Nov 9, 2023

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

@Nianzu Nianzu reopened this Nov 9, 2023
@Amchanie
Copy link

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

@dipeshSam
Copy link

@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.

@KRSHH KRSHH linked a pull request Oct 29, 2024 that will close this issue
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.

4 participants