In this video we’ll learn how to create cool looking modern buttons with images in CustomTkinter.

Images in CustomTkinter are pretty simple, we just need to use Pillow and a little bit of code.

We’ll look at using images, moving those images around, and also changing colors of buttons and their hover colors as well.

Python Code: buttons_cust.py
(Github Code)

from tkinter import *
import customtkinter
from PIL import Image, ImageTk


customtkinter.set_appearance_mode("dark")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue")  # Themes: blue (default), dark-blue, green

root = customtkinter.CTk()

root.title('Codemy.com - Custom Buttons With Images')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x170")

# Define Our Images

add_folder_image = ImageTk.PhotoImage(Image.open("test_images/add-folder.png").resize((20,20), Image.ANTIALIAS))
add_list_image = ImageTk.PhotoImage(Image.open("test_images/add-list.png").resize((20,20), Image.ANTIALIAS))

# Create Our Buttons
button_1 = customtkinter.CTkButton(master=root, image=add_folder_image, text="Add Folder", width=190, height=40, compound="top")
button_1.pack(pady=20, padx=20)

button_2 = customtkinter.CTkButton(master=root, image=add_list_image, text="Add Item", width=190, height=40, compound="right", 
	fg_color="#D35B58", hover_color="#C77C78")
button_2.pack(pady=10, padx=20)	



root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...