BlackGuard26 BlackGuard26 - 1 year ago 241
Python Question

Tkinter check if entry box is empty

Could someone tell me how to check if an Tkinter entry box is empty?

In other words if it doesn't have a value assigned to it.

Language has to be Python.

Thank you for your help!

Answer Source

You can get the value and then check its length:

if len(the_entry_widget.get()) == 0:

You can get the index of the last character in the widget. If the last index is 0 (zero), it is empty:

if the_entry_widget.index("end") == 0:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download