Установить изображение (palplot) в кнопку CustomtkinterPython

Программы на Python
Anonymous
Установить изображение (palplot) в кнопку Customtkinter

Сообщение Anonymous »

Как установить изображение (palplot, созданное с помощью seaborn) в кнопку Customtkinter (CTkButton)?
В следующем MWE я создал кнопку и изображение, но добавление изображения с помощью image = image в определении кнопки не работает.< /p>
MWE
root = CTk()

# Create figure
image = plt.Figure()
ax = image.add_subplot()
# Create canvas to hold figure
canvas = FigureCanvasTkAgg(image, master=root)
canvas.get_tk_widget().grid(column=0, row=1)

ax.imshow(np.arange(500).reshape(1, 500),
cmap=matplotlib.colors.ListedColormap(list(color_palette("flare", 500))),
aspect="auto")
canvas.draw_idle()

# Create button
button = CTkButton(root, text="some button with an image", image = image)
button.grid(column=0, row=0)

root.mainloop()


Подробнее здесь: https://stackoverflow.com/questions/790 ... ter-button

Вернуться в «Python»