TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.6k stars 1.09k forks source link

CTkCanvas.coords(id) not returning the coords. #1419

Open VasigaranAndAngel opened 1 year ago

VasigaranAndAngel commented 1 year ago

I have been using your CustomTkinter library and have noticed that in the coords() method CTkCanvas,

https://github.com/TomSchimansky/CustomTkinter/blob/09e584634c867f2b6074fcbfe41cba80d2b78c66/customtkinter/windows/widgets/core_rendering/ctk_canvas.py#L83-L99

the super().coords() method is being called but the returned values are not being returned. Instead, the method seems to be used for its side effects.

image

it returns a list of coordinates for the item given as an argument.

I wanted to bring this to your attention as it may be a design choice that you made intentionally, but I also wanted to suggest that capturing and utilizing the returned values from super().coords() could be beneficial in certain cases. Thank you for your time and for creating CustomTkinter! ❤️

VasigaranAndAngel commented 1 year ago

@TomSchimansky, Can I fix this?

rcrist commented 6 months ago

As a work around, I am using a standard Tkinter canvas which does return the coordinates.

MrHarcombe commented 3 months ago

Would greatly appreciate this being fixed so I can get back to using the standard release versions of the library, rather than having to work on a locally modified version...

DeltaGa commented 3 months ago

Here would be a durable fix to the issue.

    def coords(self, tag_or_id, *args):
        if type(tag_or_id) == str and "ctk_aa_circle_font_element" in self.gettags(tag_or_id):
            coords_id = self.find_withtag(tag_or_id)[0]  # take the lowest id for the given tag
            super().coords(coords_id, *args[:2])

            if len(args) == 3:
                super().itemconfigure(coords_id, font=("CustomTkinter_shapes_font", -int(args[2]) * 2), text=self._get_char_from_radius(args[2]))

        elif type(tag_or_id) == int and tag_or_id in self._aa_circle_canvas_ids:
            super().coords(tag_or_id, *args[:2])

            if len(args) == 3:
                super().itemconfigure(tag_or_id, font=("CustomTkinter_shapes_font", -args[2] * 2), text=self._get_char_from_radius(args[2]))

        else:
            coords = super().coords(tag_or_id, *args)
            if not coords:
                return [0, 0, 0, 0]  # Return default coordinates if None
            return coords