Hello.
There are 2 problems with your code.
The first problem arises from the fact that paste_clipboard() method doesn't do any text manipulation but just emits "paste-clipboard" signal. It's the default handler for gtk.Entry's "paste-clipboard" signal that does the real work. But before that handler is called, gtk takes care of all pending events with higher priority. This is why you get empty txt when printing - since nothing has been added to the gtk.Entry yet.
The usual method to handle these kind of situations is to process all the events inside you function with this construct:
Code:
while gtk.events_pending() :
gtk.main_iteration()
But here comes the second problem. This method resolves the problem when the application is written in C, but pygtk seems to be "immune" to that call (I'm no pygtk expert, so I cannot tell you why exactly this construct is not working here).
BTW, your last method that resolved your problem works as expected because no fiddling with events is done - the text is retrieved and inserted at the exact moment you call your functions.