Ich habe CTK verwendet, um die Ecken meiner Schaltflächen abzurunden. Es hat funktioniert, aber nicht wie erwartet.
Im Hintergrund der Schaltfläche befindet sich immer noch etwas, das die abgerundeten Ecken nicht erhält
Bild dazu
Ich verstehe allerdings nicht, was die Ursache ist, vielleicht liegt es daran, dass sich die Schaltfläche in einem Raster befindet?
import customtkinter as ctk
import webbrowser
from PIL import Image
def on_press(event, button, ID):
button.configure(bg_color="#009A5F") # Darker shade of #00B06F
open_place(ID) # Open the place when button is pressed
return "break" # Prevent the default button behavior and animation
def on_release(event, button):
button.configure(bg_color="#00B06F") # Original color
# Create a frame for each entry in the data and arrange in a grid
row, column = 0, 0
for name, info in Data.items():
frame = ctk.CTkFrame(root, width=CWidth, height=CHeight, corner_radius=20) # Added corner_radius
frame.grid_propagate(False) # Prevent the frame from resizing to the content
# Game name label at the top with updated styling
game_name_label = ctk.CTkLabel(frame, text=name, font=("Arial", 12, "bold"), anchor="center", text_color="white", bg_color="#111216", corner_radius=10)
game_name_label.grid(row=1, column=0, sticky="ew", padx=5, pady=5)
# Play button at the bottom, 100% width with custom button color and rounded corners
button = ctk.CTkButton(frame, text="Play", fg_color="#00B06F", hover_color="#009A5F", height=40, corner_radius=15)
button.grid(row=2, column=0, sticky="ew", padx=5, pady=(3, 5)) # Use sticky='ew' to stretch it horizontally
# Bind the button press and release events
button.bind("", lambda event, btn=button, ID=info["ID"]: on_press(event, btn, ID))
button.bind("", lambda event, btn=button: on_release(event, btn))
# Add the frame to the root window in a grid, with 5px padding between frames
frame.grid(row=row, column=column, padx=5, pady=5)
# Configure the grid of the frame to have 3 rows and 1 column, and stretch elements
frame.grid_rowconfigure(0, weight=1) # Label row stays at the top without stretching
frame.grid_rowconfigure(1, weight=0) # Empty row to make sure there's space for the label and button
frame.grid_rowconfigure(2, weight=0) # Button row stays at the bottom without stretching
# Configure the column of the frame
frame.grid_columnconfigure(0, weight=1) # The single column will expand horizontally
Ich habe CTK verwendet, um die Ecken meiner Schaltflächen abzurunden. Es hat funktioniert, aber nicht wie erwartet. Im Hintergrund der Schaltfläche befindet sich immer noch etwas, das die abgerundeten Ecken nicht erhält Bild dazu Ich verstehe allerdings nicht, was die Ursache ist, vielleicht liegt es daran, dass sich die Schaltfläche in einem Raster befindet? [code]import customtkinter as ctk import webbrowser from PIL import Image
def on_press(event, button, ID): button.configure(bg_color="#009A5F") # Darker shade of #00B06F open_place(ID) # Open the place when button is pressed return "break" # Prevent the default button behavior and animation
def on_release(event, button): button.configure(bg_color="#00B06F") # Original color
# Create a frame for each entry in the data and arrange in a grid row, column = 0, 0 for name, info in Data.items(): frame = ctk.CTkFrame(root, width=CWidth, height=CHeight, corner_radius=20) # Added corner_radius frame.grid_propagate(False) # Prevent the frame from resizing to the content
# Game name label at the top with updated styling game_name_label = ctk.CTkLabel(frame, text=name, font=("Arial", 12, "bold"), anchor="center", text_color="white", bg_color="#111216", corner_radius=10) game_name_label.grid(row=1, column=0, sticky="ew", padx=5, pady=5)
# Play button at the bottom, 100% width with custom button color and rounded corners button = ctk.CTkButton(frame, text="Play", fg_color="#00B06F", hover_color="#009A5F", height=40, corner_radius=15) button.grid(row=2, column=0, sticky="ew", padx=5, pady=(3, 5)) # Use sticky='ew' to stretch it horizontally
# Add the frame to the root window in a grid, with 5px padding between frames frame.grid(row=row, column=column, padx=5, pady=5)
# Configure the grid of the frame to have 3 rows and 1 column, and stretch elements frame.grid_rowconfigure(0, weight=1) # Label row stays at the top without stretching frame.grid_rowconfigure(1, weight=0) # Empty row to make sure there's space for the label and button frame.grid_rowconfigure(2, weight=0) # Button row stays at the bottom without stretching
# Configure the column of the frame frame.grid_columnconfigure(0, weight=1) # The single column will expand horizontally
Ich versuche, einen Knopf mit abgerundeten Ecken und einem benutzerdefinierten Ripple -Effekt zu erstellen. Ich habe eine ripple zeichnbare ( custom_ripple.xml ) und angewendet mit Android:...
Abgerundete Ecken der Kartenansicht
Ich möchte Erstellen Sie die Schnittstelle wie oben gezeigt. Die Bilder sind nicht fixiert, was bedeutet, dass ich Bilder auf andere übertragen kann. Ich möchte...
Ich möchte, dass meine UICollectionViewCells abgerundete Ecken und Schatten fallen lassen, aber ich bin auf ein Problem gestoßen, in dem ich anscheinend nur das eine oder andere haben kann, aber...
Ich arbeite an einer Windows Forms-Anwendung, in der ich Code implementiert habe, um die Ecken des Formulars zu krümmen. Während der Code das Formular selbst erfolgreich krümmt, funktioniert er nicht...