Reputation: 41
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.
Upvotes: 2
Views: 2112
Reputation: 41
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()
Upvotes: 2
Reputation: 1673
You can set the state of Entry widget to DISABLED.
Example:-
win = tk.Tk()
ent = Entry(win, state=DISABLED)
ent.pack()
Upvotes: 3