Tkinter nice buttons

This time i am gonna show how to make a nice button with tkinter using images.

This is an example

This was done with this image

Here are other examples

The code is this

# custom made buttons for tkinter

import tkinter as tk


root = tk.Tk()

def image(smp):
    img = tk.PhotoImage(file="red2.png")
    img = img.subsample(smp, smp)
    return img


but = tk.Button(
    root,
    bd=0,
    relief="groove",
    compound=tk.CENTER,
    bg="white",
    fg="yellow",
    activeforeground="pink",
    activebackground="white",
    font="arial 30",
    text="Click me",
    pady=10,
    # width=300
    )

img = image(2) # 1=normal, 2=small, 3=smallest
but.config(image=img)
but.pack()


root.mainloop()

The video


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts