Re: [pygtk] Executing commands without callbacks...
On Tue, Jan 20, 2004 at 09:31:35AM -0300, Michel Thadeu wrote: > The problem is that in the 3rd test I need to open a popup window > calling some user interaction (inserting a floppy)... The popup opens > but the idle_add stills running (I want the idle_add stops when the > popup opens and start when the popup closes... I'm not sure what you mean. You've idle_add()ed a function, and this function needs to open a popup window? Why not call a gtk.mainloop() when your popup is opened? That's the standard way of waiting for a dialog to run.. something like: def my_callback(self, *args): # ... w = gtk.GtkWindow() w.connect("delete_event", gtk.mainquit) # You'll need to w.connect() other signals to call mainquit too # if the dialog has something like a Close/OK button. w.show() # This blocks until the popup is closed or deleted gtk.mainloop() w.hide() (Normally I'd encapsulate the window creation, show and hide inside a class like MyDialog which has a run() method that takes care of all of that and returns a value). Take care, -- Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Executing commands without callbacks...
Hi Christian, sorry I mail you a private message, I didn't see the message was to you... The best choice for me is the idle_add(...) function. I will make a checklist, a couple of tests will be make and each interaction I want to do another thing... I do something simple: ... self.iteraction=0 gtk.idle_add(make_test) ... def make_test(self): ret=test(self.iteraction) self.iteraction+=1 return ret ... def test(self, iteraction): list=(self.test1, self.test2, self.test3, self.test4) try: self.model.append(row=lista[n]()) except: return 0 return 1 ... The model is a gtk.ListStore widget and each function in the list return a tuple formated to this model... The problem is that in the 3rd test I need to open a popup window calling some user interaction (inserting a floppy)... The popup opens but the idle_add stills running (I want the idle_add stops when the popup opens and start when the popup closes... I have some ideas I will try to implement, but if someone have another suggestion :) Thanks for all help Chistian! = -- Michel Thadeu Sabchuk Curitiba/PR __ Yahoo! GeoCities: a maneira mais fácil de criar seu web site grátis! http://br.geocities.yahoo.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Executing commands without callbacks...
On Mon, Jan 19, 2004 at 12:48:06PM -0300, Michel Thadeu wrote: > The problem is that I execute a gtk.main() to put the program in the > mainloop... I need to populate the liststore, but or I populate before > showing all the widgets with gtk.main() or I execute next to the > gtk.main(), in this case the list are populated only when I close the > app... > > Is there a way to define a callback when the program shows the app? Yes, and there are a couple of different ways to do it. For instance, you can: a) Connect to the main window's "map" or "realize" signal and populate the list there. IIRC that map can be issued multiple times, so you'll need to avoid repopulating. b) Use an idle handler, which runs a function or method during the mainloop (gtk.idle_add(func_ref)) There are other ways (`invente a sua'), each with slightly different semantics. If you have a specific problem, you can ask and we'll try to solve it. Take care, -- Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/