Я использовал CTK, чтобы вокруг углов моих кнопок, он работал, но не так, как ожидалось.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
Подробнее здесь: https://stackoverflow.com/questions/793 ... -got-edges
CustomTkinter: Фон кнопки с округлым углом все еще получил края ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
BottomNavigationView никогда не заполняет системные кнопки навигации от края до края.
Anonymous » » в форуме JAVA - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-
-
-
BottomNavigationView никогда не заполняет системные кнопки навигации от края до края.
Anonymous » » в форуме Android - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-
-
-
BottomNavigationView никогда не заполняет системные кнопки навигации от края до края.
Anonymous » » в форуме JAVA - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-
-
-
BottomNavigationView никогда не заполняет системные кнопки навигации от края до края.
Anonymous » » в форуме JAVA - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-