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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -