For some reason presendt() didn't work for me. It didn't give me an error or anything, just nothing happened.
What I ended up getting to work is: To hide the window: self.window.set_skip_taskbar_hint(True) self.window.iconify() And to unhide: self.window.deiconify() self.window.set_skip_taskbar_hint(False) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julio Carlos Menéndez Sent: Thursday, November 15, 2007 6:10 PM To: pygtk@daa.com.au Subject: Re: [pygtk] (no subject) This code is working propertly, i use present to bring back the window because according to the documentation of pygtk: "The present() method presents a window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user's platform, window manager, and preferences. If the window is hidden, this method calls the the gtk.Widget.show() method as well. This method should be used when the user tries to open a window that's already open. Say for example the preferences dialog is currently open, and the user chooses Preferences from the menu a second time; use the present() method to move the already-open dialog where the user can see it." So, here is the code for what I guess you want: import pygtk pygtk.require('2.0') import gtk class Application(object): def __init__(self): self.statusicon = gtk.status_icon_new_from_stock('gtk-about') self.statusicon.set_visible(True) self.statusicon.connect('activate', self.on_activate) self.window = gtk.Window() self.window.connect('delete-event', self.on_delete_event) self.window.show_all() def on_activate(self, widget, data=None): if self.window.get_property('visible'): self.window.hide() else: self.window.present() def on_delete_event(self, widget, data=None): self.statusicon.set_visible(False) gtk.main_quit() if __name__ == '__main__': app = Application() gtk.main() Greetings. On Thu, 15 Nov 2007 17:21:41 -0500 "McBride, Nathan" <[EMAIL PROTECTED]> wrote: > Actually, it doesn't seem to be re-creating the window after all. > However, I can't seem to figure out how to bring the window back. > > I have tried: > > self.window.show() > self.window.deiconify() > self.window.ahow_all() > > What is the correct way to do this? > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Julio Carlos Menéndez Sent: Thursday, November 15, 2007 > 4:08 PM To: pygtk@daa.com.au > Subject: Re: [pygtk] (no subject) > > If you put all this code: > > statusIcon = gtk.StatusIcon() > > menu = gtk.Menu() > menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) > menuItem.connect('activate', icon_show_about) > menu.append(menuItem) > menuItem = gtk.SeparatorMenuItem() > menu.append(menuItem) > menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) > menuItem.connect('activate', quit_cb, statusIcon) > menu.append(menuItem) > > # statusIcon.set_from_stock(gtk.STOCK_HOME) > statusIcon.set_from_file("pixmaps/dmcal.png") > statusIcon.set_tooltip("DM-Crypt & LUKS Encryption Suite") > statusIcon.connect('activate', activate_icon_cb) > statusIcon.connect('popup-menu', popup_menu_cb, menu) > statusIcon.set_visible(True) > > inside the __init__ method and every method you create should have the > syntax '<method_name>(self,<parameters>)' to make it an instance > method. Doing all that you should be able to use any > self.<whatever_you_want> > > The method should be like this: > def activate_icon_cb(self, widget): > if self.window.visible(): > self.window.hide() > else: > self..window.show() > > Hope this works for you. > > On Thu, 15 Nov 2007 13:15:35 -0500 > "McBride, Nathan" <[EMAIL PROTECTED]> wrote: > > > run the program and the main window comes up with the status icon. > > When I minimize the window, instead of minimizing it, it hides it. > > So the window is gone but the icon is still in the tasktray. > > (minimizing to tasktray) What I am trying to accomplish is that when > > you click the tasktray icon then the window unhides and comes back. > > > > everything works flawlessly except i can't get: > > > > def activate_icon_cb(widget, data = None): > > pass > > > > to have access to self.window from the __init__ to run the > > self.window.show(). I'have tried setting it up like: > > > > def activate_icon_cb(self, widget, data = None): > > pass > > > > # statusIcon.set_from_stock(gtk.STOCK_HOME) > > statusIcon.set_from_file("pixmaps/dmcal.png") > > statusIcon.set_tooltip("DM-Crypt & LUKS Encryption Suite") > > statusIcon.connect('activate', activate_icon_cb(self)) > > statusIcon.connect('popup-menu', popup_menu_cb, menu) > > statusIcon.set_visible(True) > > > > but it says self isn't defined. When I tried recalling the widget > > from the glade file and showing it that way instead of showing it it > > just made another. But I have to bring the first on back up not make > > a new one. > > > > Thanks for helping me with this. > > > > Nate > > > > Here is the majority of the code: > > > > class dmcalGTK: > > """The DMCal Application""" > > > > def __init__(self): > > > > #Set the glade file > > self.gladefile = "dmcal.glade" > > self.wTree = gtk.glade.XML(self.gladefile, "dmcalMain") > > > > self.window = self.wTree.get_widget("dmcalMain") > > self.window.connect('window-state-event', > > self.window_event) > > > > #Create our dictionary and connect it > > dic = {"on_create_container_activate" : > > self.create_container_activate, > > "on_dmcalMain_destroy" : self.dmcalMain_destroy, > > "on_aboutMenuItem_activate" : self.showAbout, > > "on_quitButton_clicked" : self.dmcalMain_destroy, > > "on_newButton_clicked" : > > self.create_container_activate, > > "on_addButton_clicked" : self.showFileSelection, > > "on_quitmenuitem_activate" : > > self.dmcalMain_destroy, "on_removeButton_clicked" : > > self.removecontainer, "on_saveMenuItem_activate" : self.savelist} > > self.wTree.signal_autoconnect(dic) > > > > preferencesMI = > > self.wTree.get_widget("preferencesMenuItem") > > preferencesMI.set_sensitive(0) > > > > #Setup the treeview > > self.treeview = self.wTree.get_widget('treeview2') > > > > #Create the liststore model to use with the treeview > > #Pattern: ICON, NAME TEXT, PATH TEXT > > self.treelist = gtk.ListStore(gtk.gdk.Pixbuf, str, str, > > str) > > #Attatch the liststore model to the treeview > > self.treeview.set_model(self.treelist) > > > > #Get the icons > > self.yes = self.treeview.render_icon('gtk-yes', > > gtk.ICON_SIZE_SMALL_TOOLBAR) > > self.no = self.treeview.render_icon('gtk-no', > > gtk.ICON_SIZE_SMALL_TOOLBAR) > > > > #Setup the columns on the listview > > > > column = gtk.TreeViewColumn('', gtk.CellRendererPixbuf(), > > pixbuf=0) > > self.treeview.append_column(column) > > column = gtk.TreeViewColumn('Name', gtk.CellRendererText(), > > text=1) > > self.treeview.append_column(column) > > column = gtk.TreeViewColumn('Location', gtk.CellRendererText(), > > text=2) > > self.treeview.append_column(column) > > column = gtk.TreeViewColumn('Mount Point', > > gtk.CellRendererText(), text=3) > > self.treeview.append_column(column) > > > > self.treelist.append([self.yes, 'container.enc', > > '/home/nomb/container.enc', '/media/enc']) > > > > self.treeselection = self.treeview.get_selection() > > self.treeselection.select_path(0) > > > > if commands.getoutput("whoami") != "root": > > print "Non-Root - Limited functionality..." > > > > #Disable create new container menu entry > > newcontainerMenuItem = > > self.wTree.get_widget("create_container") > > newcontainerMenuItem.set_sensitive(0) > > > > #Disable create new container button > > newcontainerButton = > > self.wTree.get_widget("newButton") > > newcontainerButton.set_sensitive(0) > > > > #Disable mount button > > mntButton = self.wTree.get_widget("mountButton") > > mntButton.set_sensitive(0) > > > > #Disable un-mount button > > unmntButton = self.wTree.get_widget("unmountButton") > > unmntButton.set_sensitive(0) > > > > #Set alert message to status bar > > statusbar = self.wTree.get_widget("statusbar1") > > statusbarid = statusbar.get_context_id("need root") > > statusbar.push(statusbarid, "Some functions require root > > permissions and path... (su -)") > > > > > > def quit_cb(widget, data = None): > > if data: > > data.set_visible(False) > > gtk.main_quit() > > > > def popup_menu_cb(widget, button, time, data = None): > > if button == 3: > > if data: > > data.show_all() > > data.popup(None, None, None, 3, time) > > pass > > > > def activate_icon_cb(widget, data = None): > > pass > > > > def icon_show_about(widget, data = None): > > dmcalDialog = dmcalAbout() > > result = dmcalDialog.run() > > > > statusIcon = gtk.StatusIcon() > > > > menu = gtk.Menu() > > menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) > > menuItem.connect('activate', icon_show_about) > > menu.append(menuItem) > > menuItem = gtk.SeparatorMenuItem() > > menu.append(menuItem) > > menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) > > menuItem.connect('activate', quit_cb, statusIcon) > > menu.append(menuItem) > > > > # statusIcon.set_from_stock(gtk.STOCK_HOME) > > statusIcon.set_from_file("pixmaps/dmcal.png") > > statusIcon.set_tooltip("DM-Crypt & LUKS Encryption Suite") > > statusIcon.connect('activate', activate_icon_cb) > > statusIcon.connect('popup-menu', popup_menu_cb, menu) > > statusIcon.set_visible(True) > > > > def window_event(self, widget, event): > > #print event.new_window_state > > if event.new_window_state == gtk.gdk.WINDOW_STATE_ICONIFIED: > > self.window.hide() > > > > ==================== > > This email/fax message is for the sole use of the intended > > recipient(s) and may contain confidential and privileged > > information. Any unauthorized review, use, disclosure or > > distribution of this email/fax is prohibited. If you are not the > > intended recipient, please destroy all paper and electronic copies > > of the original message. > > > -- > Julio Carlos Menéndez > GNU/Linux User #403551 > http://deltha.uh.cu/~juliocarlos > ==================== > This email/fax message is for the sole use of the intended > recipient(s) and may contain confidential and privileged information. > Any unauthorized review, use, disclosure or distribution of this > email/fax is prohibited. If you are not the intended recipient, please > destroy all paper and electronic copies of the original message. > _______________________________________________ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ -- Julio Carlos Menéndez GNU/Linux User #403551 http://deltha.uh.cu/~juliocarlos ==================== This email/fax message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of this email/fax is prohibited. If you are not the intended recipient, please destroy all paper and electronic copies of the original message. _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/