on-internet
← Community

How to make a rounded button tkinter?

Stack Overflow ·

I am trying to get rounded buttons for my script using tkinter. I found the following code in an answer to How to make a Button using the tkinter Canvas widget?: from tkinter import * import tkinter as tk class CustomButton(tk.Canvas): def __init__(self, parent, width, height, color, command=None): tk.Canvas.__init__(self, parent, borderwidth=1, relief="raised", highlightthickness=0) self.command = command padding = 4 id = self.create_oval((padding,padding, width+padding, height+padding), outline=color, fill=color) (x0,y0,x1,y1) = self.bbox("all") width = (x1-x0) + padding height = (y1-y0) + p

Comments

Sign in or sign up to comment and upvote.

No comments yet.