2

How can I disable keyboard input entries when using Entry on Tkinter in python I was coding for a calculator project in python. So I need to make a screen like text box using Entry.
I couldn't remove keyboard inputs from the Entry field.

3

2 Answers 2

3

You can set the state of Entry widget to DISABLED.

Example:-

win = tk.Tk()
ent = Entry(win, state=DISABLED)
ent.pack() 
Sign up to request clarification or add additional context in comments.

Comments

2

you can disable keyboard characters from an Entry field in Tkinter using:

from tkinter import *
root=Tk()

txtDisplay = Entry(root, width=28, justify=RIGHT)    
txtDisplay.grid(row=0, column=0, columnspan=5, pady=1)
txtDisplay.bind("<Key>", lambda e: "break")          # Disable characters from keyboard

root.mainloop()

1 Comment

This won't prevent you from pasteing data with the mouse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.