I will tell you 2 approaches to do that.
I would suggest using a tkinter.messagebox
to show the error(or info ) to the user because it will disable the root
window until it remains open. It plays sounds as per system preferences and allows pressing enter to close out the pop-up
Like this::
import tkinter as tk
import tkinter.messagebox as msgb # use your preferred import style
def submit():
if e.get() == 'something': # check input here
doSomething()
else:
msgb.ShowError('Invalid input', 'seems like you entered incorrect name')
root = tk.Tk()
e = tk.Entry(root)
e.pack()
btn = tk.Button(root, text='Submit', command=submit)
btn.pack()
root.mainloop()
2nd Approach:
If you really need to only use a Toplevel window and have to grey out entry box (and/or the button) - here is how
import tkinter as tk
def submit():
if e.get() == 'something': # check input here
doSomething()
else:
e.configure(state=tk.DISABLED)
btn.configure(state=tk.DISABLED)
newWindow = tk.Toplevel()
showSomethingHere()
root = tk.Tk()
e = tk.Entry(root)
btn = tk.Button(root, text='Submit', command=submit)
e.pack()
btn.pack()
root.mainloop()