How to disable an entry widget in Tkinter

Overview

Tkinter isĀ the standard GUI library for Python. We can create graphical applications using this library. In this Answer, we'll learn to disable an entry widget in Tkinter.

The entry widget is used to take input from the user. If we want to disable it, we need to pass disabled as a value to the state parameter in the config method.

Syntax

entry_widget.config(state="disabled")

Example

from tkinter import *

#get tinker instance frame
window = Tk()

#set window size
window.geometry("600x400")


#normal entry widget
entry=Entry(window, width= 30)
entry.pack(pady=20)

#disabled entry widget
entry_disabled=Entry(window, width= 30)
entry_disabled.pack(pady=20)
entry_disabled.config(state= "disabled")


window.mainloop()

Explanation

  • Line 1: We import everything from tkinter package.
  • Line 4: We create an instance of the Tkinter frame and store it in the window variable. We do so to keep widgets inside of the Tkinter frame in order to display them.
  • Line 7: We set the window size of the Tkinter frame.
  • Line 11–12: We create the normal entry widget, with which users can interact.
  • Line 15–17: We create the entry widget and disable it using the config method and pass disabled as a value to the state parameter.

After disabling, users won't be able to interact with the second entry widget.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
šŸ† Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved