Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  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!

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
Danke, sehr hilfreich! – snowflake Jun 19 '12 at 20:01
If you are using Quickly and you've added your widget through Glade, you can also use self.ui.entry1.get_text(). Note that this is not standard GTK, simply a nice shortcut Quickly offers. – David Planella Jun 20 '12 at 7:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.