[pygtk] make button insenstive when the contents of gtk.Entry
have changed
Samuel Cormier-Iijima
sciyoshi at gmail.com
Tue Nov 14 15:04:12 WST 2006
You should try connecting to the notify::property signal, which gets
emitted when the given property changes. A quick example:
import gtk
# gets called whenever the text changes
def text_changed(entry, prop):
if entry.props.text == '':
button.set_sensitive(False)
else:
button.set_sensitive(True)
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
vbox = gtk.VBox(False, False)
entry = gtk.Entry()
button = gtk.Button(stock='gtk-ok')
# initially insensitive
button.set_sensitive(False)
# connect the signal to whenever the text changes
entry.connect('notify::text', text_changed)
vbox.pack_start(entry, False, True)
vbox.pack_start(button, True, True)
window.add(vbox)
window.show_all()
gtk.main()
Samuel Cormier-Iijima
On 11/14/06, John Kelly <kelly_worth2003 at yahoo.co.uk> wrote:
> Hello everyone,
>
> I need some help in making a gtk.Button insensitive when a gtk.Entry
> contents have changed. I have tried many different signals, each of them
> failed to do what i wanted. I basically want the exact same behaviour as
> gaim's add account dialog. In the add account dialog, if the screen name
> entry has no characters in it then the save button remains insensitive.
> The save button appears active when characters are entered in the
> screenname entry.
>
> Regards,
> John
>
>
>
> ___________________________________________________________
> Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal
> http://uk.docs.yahoo.com/nowyoucan.html
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
More information about the pygtk
mailing list