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

So, I'm depeloping a Python/GTK app which, after showing an assistant, it hides the assistant's window and runs an external app. The problem is that window.hide() doesn't works if, after the command, there's an app call using os.system() or call(). When the call is done, the window seems to hang and it doesn't disappears until all the calls are done. So... what can be done?

share|improve this question
We are making a client/server app, and we have some troubles with gtk, it seams to lock our thread in the Gtk.main(). So we might be interested about using your solution, but where did you put those lines ? – Audrey-ShowMyFaves Jun 24 '12 at 21:32
Yep, I had the same problem with an app which I've done. Let me check... – espectalll Jun 24 '12 at 21:43
OK, it seems to fix the hanged thread error. Just insert it before the code which causes the problem, and done! :) – espectalll Jun 24 '12 at 21:49
Wait... I'm not sure, try it anyway. – espectalll Jun 24 '12 at 21:52
up vote 1 down vote accepted

After some time googling possible solutions, I've found this simple answer, which waits to GTK until it finished all its working tasks. You may think that makes the app slower, but the difference is almost unexistent.

This workaround can be used with any version of Python. It works with PyGTK and with GTK+3 (with GTK+3, change gtk per Gtk... :P )

while gtk.events_pending():

Just add this before the code which causes the problem... and done! :)

share|improve this answer

In my applications I tend to replace os.system() and with subprocess.Popen (see

share|improve this answer
I've been using subprocess.Popen recently and it's really delightful. If only I knew back then! – espectalll Jan 27 at 9:25

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.