Hide Python Tkinter Text widget border
Last Updated :
27 May, 2024
Tkinter is a standard GUI library for Python, providing tools to create graphical user interfaces easily. When designing interfaces, developers often encounter the need to customize widget appearances, including removing widget borders. Borders can sometimes clash with the desired aesthetic or layout of the application. This article explores what widget borders are in Tkinter and provides two methods to remove them.
What is the Widget Border in Tkinter?
In Tkinter, widgets such as buttons, labels, and frames have borders by default. These borders can be visual edges that surround the widget, giving it a distinct boundary from other elements in the GUI. Borders help in defining widget areas but may not always align with the visual design requirements of an application. Hence, knowing how to remove or customize these borders becomes crucial for fine-tuning the appearance of the interface.
How To Get Rid Of Widget Border In Tkinter?
Below, are the ways of How To Get Rid Of the Widget Border In Tkinter.
Method 1: Using the bd (border-width) Attribute
The simplest way to remove the border of a widget is by setting its bd (border-width) attribute to 0. The bd attribute specifies the width of the border around the widget. By default, many widgets come with a non-zero border width.
Python
import tkinter as tk
def create_window():
root = tk.Tk()
root.title("No Border Example")
# Button with no border
no_border_button = tk.Button(root, text="No Border", bd=0)
no_border_button.pack(padx=10, pady=10)
root.mainloop()
create_window()
In this example:
- A Tkinter window is created with the title "No Border Example".
- A button widget is created with the text "No Border" and its bd attribute set to 0.
- The button is packed into the window, and the main event loop is started.
Setting bd=0 removes the border from the button, giving it a flat appearance.
Output

Method 2: Using the highlightthickness Attribute
Another approach to remove the border, especially the focus border (highlight border) around widgets, is to set the highlightthickness attribute to 0. This attribute controls the width of the highlight border that appears when the widget is focused.
Python
import tkinter as tk
def create_window():
root = tk.Tk()
root.title("No Highlight Border Example")
# Entry widget with no highlight border
no_highlight_entry = tk.Entry(root, highlightthickness=0)
no_highlight_entry.pack(padx=10, pady=10)
root.mainloop()
create_window()
In this example:
- A Tkinter window is created with the title "No Highlight Border Example".
- An entry widget is created with its highlightthickness attribute set to 0.
- The entry widget is packed into the window, and the main event loop is started.
Setting highlightthickness=0 removes the highlight border from the entry widget, resulting in a cleaner look.
Output

Similar Reads
Python Tkinter - Text Widget Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs.Note: For more information, refer to Python GUI â tkinter Text WidgetText Widget is used wh
5 min read
Python Tkinter - Create Button Widget The Tkinter Button widget is a graphical control element used in Python's Tkinter library to create clickable buttons in a graphical user interface (GUI). It provides a way for users to trigger actions or events when clicked.Note:Â For more reference, you can read our article:What is WidgetsPython Tk
6 min read
Python Tkinter - Frame Widget Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicatio
3 min read
Python Tkinter - Entry Widget Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.In Python3 Tkinter is come
5 min read
How to Set Border of Tkinter Label Widget? The task here is to draft a python program using Tkinter module to set borders of a label widget. A Tkinter label Widget is an Area that displays text or images. We can update this text at any point in time. ApproachImport moduleCreate a windowSet a label widget with required attributes for borderP
2 min read
Python Tkinter - ScrolledText Widget Tkinter is a built-in standard python library. With the help of Tkinter, many GUI applications can be created easily. There are various types of widgets available in Tkinter such as button, frame, label, menu, scrolledtext, canvas and many more. A widget is an element that provides various controls.
3 min read