You could attach a handler to the gtk.Entry "focus-out-event" signal and then do the checking and set the foreground in the entry as the dialog runs. Technically, you could even connect to the "changed" signal which would then allow you to grey-out the "OK" button if the text was bad - this would mean you wouldn't need the loop.