How can I identify if there is text?

Multi tool use
I want to identify if there is text on canvas in tkinter.
Can anybody help me please? I have to find out if there is text to avoid an UnboundLocal Error.
Thanks!
If you want to access and update the text
variable from the global scope, do so with global
. If text
is not defined in that scope, you can catch the NameError
exception raised.
If text
is global, you can use if text not in globals()
to check if text is defined. Furthermore, you can use if globals().get('text')
which will return False
if text
is either empty or not defined:
You can do the same thing with locals()
inside a function
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.