Il giorno mer, 06/04/2011 alle 08.31 -0300, Vinicius Massuchetto ha scritto: > 2011/4/6 Pietro Battiston <m...@pietrobattiston.it>: > > Il giorno mer, 06/04/2011 alle 08.00 -0300, Vinicius Massuchetto ha > > scritto: > >> Hi list! > >> > >> I think I must be missing some signals concepts here, but I having > >> trouble reproducing the following behavior: > >> > >> 1. Click on a button; > >> 2. Hide the current window; > >> 3. Run an external script (that will open another program's window); > >> 4. Show again the PyGTK window after the external program is closed. > >> > >> For that, I've tried something like: > >> > >> class Foo: > >> > >> def __init__(self): > >> self.gladefile = gladefile > >> self.gladetree = gtk.glade.XML(self.gladefile, 'some_window') > >> self.window = self.gladetree.get_widget('some_window') > >> events = { 'on_code_submit_clicked' : self.submit } > >> self.gladetree.signal_autoconnect(events) > >> > >> def submit(self): > >> self.window.hide() > >> os.system('external_script') > >> self.window.show() > >> > >> What's happening, is that when the button is clicked, it stay pressed, > >> then the script runs, and after the external program is closed, the > >> window "blinks", being hidden and shown again. > >> > >> I also tried the "pressed" and "released" signals. > >> > >> What I can imagine is that the event is being run _during_ the > >> _clicked_ event, not after. That's why the window remain opened. I > >> couldn't find something like `gtk_signal_connect_after` [1] on the > >> glade page [2], that leaves me totally lost about it. > >> > > > > > > There may be cleaner solutions, but the first thing which comes to my > > mind is replacing > > os.system('external_script') > > with > > glib.idle_add(os.system, 'external_script') > > (and maybe replacing "os.system" with "subprocess.call" - but that's not > > pygtk-related). > > Doing `glib.idle_add (subprocess.call, ['external_script', 'param'])` > will make the window to: > > 1. Disappear; > 2. Appear with no content; > 3. Run the external script; > 4. Fill the window with content when closing the external program >
You see, that's already something! Seriously, replacing "self.window.show()" with "glib.idle_add(self.window.show)" should now get you done. Or in alternative replacing os.system('external_script') self.window.show() with glib.idle_add(self.run_script) def run_script(self): subprocess.call(['external_script', 'param']) self.window.show() Pietro _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/