Skip to content

Icon and Bind test on macOS/Linux #18

Description

@FedericoSpada

I've just made some major changes to core features; I need to test them on macOS and Linux.
I don't think there will be problems, since I've just used standard tkinter commands, but maybe those OS have some quirks that break the behaviors I've experimented with on Windows.
@ajkessel, can I ask for your help again?

ctk.set_appearance_mode("light")
ctk.set_default_color_theme("blue")

class Temp(ctk.CTk):
    def __init__(self) -> None:
        super().__init__()
        self.geometry("500x300+800+200")

        IMAGE_PATH = r"path_to_any_image"

        self.wm_iconphoto(False, ctk.CTkImage(light_image=IMAGE_PATH))
        toplevel = ctk.CTkToplevel()

        btn = ctk.CTkButton(self, corner_radius=30, height=100, width=100,
                            image={"light_image": IMAGE_PATH,
                                    "width": 50})
        btn.pack(pady=5, padx=5)

        self.count = 0
        def printevent(event: ctk.Event) -> None:
            self.count+=1
            print(f"{self.count} printevent", event, event.widget)

        btn.bind("<Activate>", printevent)
        btn.bind("<Button-1>", printevent)
        btn.bind("<ButtonRelease-1>", printevent)
        btn.bind("<Configure>", printevent)
        btn.bind("<Deactivate>", printevent)
        btn.bind("<Destroy>", printevent)
        btn.bind("<Enter>", printevent)
        btn.bind("<Expose>", printevent)
        btn.bind("<FocusIn>", printevent)
        btn.bind("<FocusOut>", printevent)
        btn.bind("<KeyPress>", printevent)
        btn.bind("<KeyRelease>", printevent)
        btn.bind("<Leave>", printevent)
        btn.bind("<Map>", printevent)
        # btn.bind("<Motion>", printevent)
        btn.bind("<MouseWheel>", printevent)
        btn.bind("<Unmap>", printevent)
        btn.bind("<Visibility>", printevent)

        tt = ctk.CTkToolTip(btn, text="ToolTip")
        self.after(2000, lambda: tt.destroy())

app = Temp()
app.mainloop()

This is the small "app" I've used: you just have to replace "path_to_any_image".
I expect the CTk icon to be the new image, while the CTkTopLevel one to be the CustomTkinter logo.

Interacting with the button, many events will be printed:

  • The most important ones to check are Enter and Leave: they should be printed just once when entering/existing the button and not while the mouse moves inside it.
  • FocusIn should be printed after clicking in any part of the button (background, label, image).
  • Map and Destroy should be invoked just once and not 3 times in a row as in the previous version.

No errors should be raised after the deletion of the CTkToolTip.

Many thanks in advance!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions