Glade GTK entry get text

Sorry for a newbie question but I could not figure out how to print a text which a user enter in a GTKEntry field after he press a button.

I design my app with glade, a simple TextEntry Field and a button. After I change the code of myappWindow.py:

 def on_button1_clicked(self, widget, data=None): print 'pressed' def entry1_changed_cb(self, widget, data=None): return widget.get_text ()

But now I couldn't find out how to print the text of the entry field after the user pressed the button.

Thanks for any help!

1 Answer

Use the get_object function of your builder to get the entry widget, for example

entry = self.builder.get_object('entry1')
print entry.get_text()

This assumes that self.builder is a Gtk.Builder instance that you assigned for example in your __init__ method using the get_builder function of the helpers module in yourproject_lib

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like