0

I'm using Python with Tkinter. As you can see in the image, how can I make a circular button? Because with the regular button, if I add an image there are the grey edges of the button. How to solve this?

import pyttsx3
import webbrowser as web
import speech_recognition as sr
from tkinter import *
from PIL import Image,ImageTk
from ctypes import windll

windll.shcore.SetProcessDpiAwareness(1)
window = Tk()
window.title("Gnocca Virtuale")
window.call("wm", "iconphoto", window._w, PhotoImage(file="trasparente.png"))
window.geometry("1100x700")
window.state("zoomed")
foto_robot = PhotoImage(file="robotagnocca.png")
etichetta_robot = Label(window,image=foto_robot)
etichetta_robot.place(relx=0,rely=0)
foto= (Image.open("bottone.png"))
resized_image= foto.resize((150,150))
new_image= ImageTk.PhotoImage(resized_image)
bottone_parla = Button(window,image=new_image)
bottone_parla.pack()
window.mainloop()

enter image description here

martineau
  • 112,593
  • 23
  • 157
  • 280
  • widgets have own background and you can't remove it. You can eventually put other widgets on `Canvas` (using `canvas.create_window(widget, ...)`) and put PNG with transparent background. (using `canvas.create_image(photoimage, ...)` ) and `bind()` mouse events to this image so it will works like button. – furas May 21 '22 at 13:14
  • @furas Ok thanks it sounds good, can you explain me more how to do this with the Canvas? Not very familiar, i updated the question with my code, i added the image in the "bottone_parla", thanks! – Forty966699669 May 21 '22 at 13:30
  • see examples on my GitHub [furas / python-examples / tkinter / __canvas__ / canvas-circle-button](https://github.com/furas/python-examples/tree/master/tkinter/__canvas__/canvas-circle-button) – furas May 22 '22 at 16:43

0 Answers0