-
Notifications
You must be signed in to change notification settings - Fork 4
CTkPopupMenu
Rudy edited this page Feb 21, 2024
·
1 revision
# PopupMenu
# Custom button
BTN_OPTION = {
"compound": "left",
"anchor": "w",
"fg_color": "transparent",
"text_color": ("black", "white"),
"corner_radius": 5,
"hover_color": ("gray90", "gray25")
}
popup_menu = PopupMenu(master=app, width=250, height=270, title="Title", corner_radius=8, border_width=0)
app.bind("<Button-3>", lambda event: do_popup(event, popup_menu), add="+") # bind app for right click: This will show the popup menu when the user right clicks on the app.
# Add buttons to the popup menu
btn1 = ctk.CTkButton(popup_menu.frame, text="Option 1", command=lambda: print("Hello"), **BTN_OPTION)
btn1.pack(expand=True, fill="x", padx=10, pady=0)
btn2 = ctk.CTkButton(popup_menu.frame, text="Option 2", command=lambda: print("Hello"), **BTN_OPTION)
btn2.pack(expand=True, fill="x", padx=10, pady=(1, 0))
btn3 = ctk.CTkButton(popup_menu.frame, text="Option 3", command=lambda: print("Hello"), **BTN_OPTION)
btn3.pack(expand=True, fill="x", padx=10, pady=(1, 0))
btn4 = ctk.CTkButton(popup_menu.frame, text="Option 4", command=lambda: print("Hello"), **BTN_OPTION)
btn4.pack(expand=True, fill="x", padx=10, pady=(1, 0))
btn5 = ctk.CTkButton(popup_menu.frame, text="Option 5", command=lambda: print("Hello"), **BTN_OPTION)
btn5.pack(expand=True, fill="x", padx=10, pady=(1, 10))
Parameter | Description |
---|---|
master |
Set parent window, the widget will spawn at where the the mouse is clicked of the parent window |
width |
Popup width (250: default) |
height |
Popup height (270: default) |
title |
Popup title (Title: default) |
corner_radius |
Popup frame corner_radius (8: default) |
border_width |
Popup frame border (0: default) |