How to make Rounded buttons in Tkinter
Last Updated :
17 Dec, 2020
Tkinter is a Python module that is used to create GUI (Graphical User Interface) applications with the help of a variety of widgets and functions. Like any other GUI module, it also supports images i.e you can use images in the application to make it more attractive.
In this article, we will discuss How to make a Rounded Button in Tkinter, There is no in-built method to make rounded buttons in Tkinter. For making the button rounded we will define borderwidth value to zero
borderwidth: It will represent the size of the border around the label. By default, borderwidth is 2 pixels. “bd” can also be used as a shorthand for borderwidth.
Step-by-step implementation:
Step 1: Create a Normal Tkinter Window.
Python3
from tkinter import *
root = Tk()
root.geometry( "400x400" )
root.mainloop()
|
Output:
Step 2: Add button and image.
Python3
login_btn = PhotoImage( file = "Image Path" )
img = Button(root, image = login_btn,
borderwidth = 0 )
img.pack()
|
Output:
Below is the full implementation:
Python3
from tkinter import *
root = Tk()
root.geometry( "400x400" )
login_btn = PhotoImage( file = "Image Path" )
img = Button(root, image = login_btn,
borderwidth = 0 )
img.pack()
root.mainloop()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...