Re: [pygtk] How to work with popup windows?
On Wed, 26 Mar 2003 14:26:22 -0500 John K Luebs <[EMAIL PROTECTED]> wrote: > On Wed, Mar 26, 2003 at 11:20:16AM -0600, John Hunter wrote: > > > "Michel" == Michel Thadeu Sabchuk <[EMAIL PROTECTED]> writes: > > > > Michel> Hi guys! I'm learning gtk and pygtk (I started with > > Michel> pygtk) and I want to know about a thing... I made a window > > Michel> and I want, when I press a button, my program create a > > Michel> popup window with a alert... I made it but I connect the > > Michel> gtk.mainquit signal to the popup and all the windows are > > Michel> killed! How to close only the popup window? > > > > Don't connect mainquit to the popup window. It does what it says -- > > quits the main program. Instead, you want to do something like > > Just as a clarification: gtk.mainquit() only quits the current > (innermost) mainloop. You can actually nest a gtk.mainloop in your code > somewhere which will run until gtk.mainquit is called. Control will then > be returned to the nested mainloop caller. Ok, I understand... I knew that gtk.mainquit would destroy all windows, but I ned to start at some point ;) Now I know that I need just to use self.window.destroy(), I found my true problem, I need to learn gtk and pygtk, not just python-libglade :) Now I will read all the pygtk tutorial, i have much time now in my holydays! Thanks and sorry about my poor english again :) -- Michel Thadeu Sabchuk Curitiba - ParanĂ¡ - Brasil ___ 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] How to work with popup windows?
On Wed, Mar 26, 2003 at 11:20:16AM -0600, John Hunter wrote: > > "Michel" == Michel Thadeu Sabchuk <[EMAIL PROTECTED]> writes: > > Michel> Hi guys! I'm learning gtk and pygtk (I started with > Michel> pygtk) and I want to know about a thing... I made a window > Michel> and I want, when I press a button, my program create a > Michel> popup window with a alert... I made it but I connect the > Michel> gtk.mainquit signal to the popup and all the windows are > Michel> killed! How to close only the popup window? > > Don't connect mainquit to the popup window. It does what it says -- > quits the main program. Instead, you want to do something like Just as a clarification: gtk.mainquit() only quits the current (innermost) mainloop. You can actually nest a gtk.mainloop in your code somewhere which will run until gtk.mainquit is called. Control will then be returned to the nested mainloop caller. You usually should not need this, you should just call gtk.Dialog.run, which creates a new mainloop and runs it for you and returns the response. > > import gtk > > window = gtk.Window() > window.show() > window.connect("destroy", gtk.mainquit) > vbox = gtk.VBox(spacing=3) > window.add(vbox) > vbox.show() > > dialog = gtk.MessageDialog( > parent = None, > flags = gtk.DIALOG_DESTROY_WITH_PARENT, > type = gtk.MESSAGE_INFO, > buttons= gtk.BUTTONS_OK, > message_format = "Your message here") > dialog.set_title('You clicked me!') > dialog.connect('response', lambda dialog, response: dialog.destroy()) > > # show the message dialog when they click > button = gtk.Button("Click me") > button.show() > button.connect("clicked", lambda *args: dialog.show()) > vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE) > > # quit the main dialog when they click > button = gtk.Button("Quit") > button.show() > button.connect("clicked", gtk.mainquit) > vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE) > > gtk.mainloop() Can't you just use a MessageDialog for the alerts as well?? --jkl ___ 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] How to work with popup windows?
> "Michel" == Michel Thadeu Sabchuk <[EMAIL PROTECTED]> writes: Michel> Hi guys! I'm learning gtk and pygtk (I started with Michel> pygtk) and I want to know about a thing... I made a window Michel> and I want, when I press a button, my program create a Michel> popup window with a alert... I made it but I connect the Michel> gtk.mainquit signal to the popup and all the windows are Michel> killed! How to close only the popup window? Don't connect mainquit to the popup window. It does what it says -- quits the main program. Instead, you want to do something like import gtk window = gtk.Window() window.show() window.connect("destroy", gtk.mainquit) vbox = gtk.VBox(spacing=3) window.add(vbox) vbox.show() dialog = gtk.MessageDialog( parent = None, flags = gtk.DIALOG_DESTROY_WITH_PARENT, type = gtk.MESSAGE_INFO, buttons= gtk.BUTTONS_OK, message_format = "Your message here") dialog.set_title('You clicked me!') dialog.connect('response', lambda dialog, response: dialog.destroy()) # show the message dialog when they click button = gtk.Button("Click me") button.show() button.connect("clicked", lambda *args: dialog.show()) vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE) # quit the main dialog when they click button = gtk.Button("Quit") button.show() button.connect("clicked", gtk.mainquit) vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE) gtk.mainloop() John Hunter ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/