python - how to make an Entry Field mandatory to enter some text? -


like in html tag attribute required=required

i want make entry widget mandatory, user must enter data in it, otherwise don't proceed next step.

how tkinter?

thank in advance

there no attribute "required" in tkinter, need write function check whether user entered data in entry or not. use function command of "next" button.

import tkinter tk  def next_step():     if mandatory_entry.get():         # user entered data in mandatory entry: proceed next step         print("next step")         root.destroy()     else:         # mandatory field empty         print("mandatory data missing")         mandatory_entry.focus_set()  root = tk.tk()  mandatory_entry = tk.entry(root)  tk.label(root, text="data *").grid(row=0, column=0) mandatory_entry.grid(row=0, column=1) tk.button(root, text='next', command=next_step).grid(row=1, columnspan=2)  root.mainloop() 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -