[Tutor] Checking if a GtkEntry is empty

Alan Gauld alan.gauld at btinternet.com
Sat Feb 25 01:07:52 CET 2012

On 24/02/12 23:49, Anthony Papillion wrote:

Add a trace to see if the method ever gets called

> def on_btnSearch_click(self, data=None):

        print "I'm in on_btnSearch_click"

>      if btnSearch.get_text() == "":
>          print "Nothing to search"
>      else:
>          print "I would do this search"

> The code above does nothing. No error, no print, nothing. Any idea?

Where are you looking for the printout?
How are you running it?

If the message I added doesn't print you need to look at how you are 
associating the method with the widget event.

You don't show us enough code for us to tell.
In fact you still don't show us enough to answer the original question 
about how to reference btnSearch. we would need to see where btnSearch 
is created.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list