CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

CTkCanvas.coords(id) not returning the coords.

Open VasigaranAndAngel opened this issue 2 years ago • 4 comments

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 avatar Apr 03 '23 18:04 VasigaranAndAngel

@TomSchimansky, Can I fix this?

VasigaranAndAngel avatar Apr 22 '23 16:04 VasigaranAndAngel

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

rcrist avatar May 15 '24 19:05 rcrist

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

MrHarcombe avatar Aug 02 '24 14:08 MrHarcombe

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

DeltaGa avatar Aug 14 '24 14:08 DeltaGa