When using pywinstyles.set_opacity on a button that was created in CustomTkinter, it causes the background to be “transparent”, just like it is supposed to be.
However this only works when I put the button/the frame that the button is mastered to, directly under the root.
Putting the frame/button into a CTKScrollFrame, causes the button to get invisible completely, and only make sit visible when hovering over it.
scrollable_frame = ctk.CTkScrollableFrame(root, fg_color="transparent")
scrollable_frame.pack(fill="both", expand=True)
scrollable_frame.grid_columnconfigure(0, weight=1)
frame = ctk.CTkFrame(scrollable_frame, width=CWidth, height=CHeight, corner_radius=20)
frame.grid_propagate(False)
button = ctk.CTkButton(frame, text="", fg_color="#00B06F", bg_color="#00B16F", hover_color="#009A5F", width=90, height=30, corner_radius=15)
button.grid(row=2, column=0, padx=5, pady=2, sticky="w")
pywinstyles.set_opacity(button, color="#00B16F")
I really want the button to be rounded, however I didn’t seem to find any other solution to do this, and I also need a scrollable frame for this
delaying the function of setting the opacity with root.after help this, however this is not a solution as I can’t wait 1 second just for this,
user28944982 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.