[pygtk] How to simplify my gtk.Entry
egbert
egbert.bouwman at hccnet.nl
Thu May 11 00:48:54 WST 2006
In the script below I have a gtk.Entry within a function;
I found a way to make the answer to this Entry available in
the surronding global namespace, but i think that there is
an easier way. Any suggestions ?
Thanks in advance.
#!/usr/bin/env python
import gtk
answer_list = []
def entry_gui(answer = None):
def entry_callback(x):
answer.append(entry.get_text())
w.destroy()
gtk.main_quit()
if answer == None: answer = []
entry = gtk.Entry()
entry.connect("activate", entry_callback)
w = gtk.Window(gtk.WINDOW_TOPLEVEL)
w.set_title("Say")
w.add(entry)
w.show_all()
entry_gui(answer_list)
gtk.main()
print "The answer is: %s" % answer_list[0]
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
========================================================================
More information about the pygtk
mailing list