Glade GTK entry get text
6,562
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
Related videos on Youtube
Author by
snowflake
Updated on September 18, 2022Comments
-
snowflake over 1 year
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!
-
snowflake almost 12 yearsDanke, sehr hilfreich!
-
David Planella almost 12 yearsIf 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.