Hi,
From: roee shlomo [mailto:roee88@gmail.com]
Sent: Thursday, February 21, 2008 10:29 AM
To: wxpython-users@lists.wxwidgets.org
Subject: wxMac: Hiding the frame on close
Hi all,
Usually (X) will cause the application to close.
I would like to change it in my main frame to the following behaviour:
-1- The close button will only hide my application and will
keep it active in the dock.
-2- Unlike minimizing, there should be no `window icon` in
the dock, only the application icon should be shown.
-3- The right click menu of the dock icon should show 'Show
Application' and not 'Hide application'.
The above is for wxMac only of course.
I have tried using EVT_CLOSE event handler like this (and
with many other variations...):
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
if wx.Platform == "__WXMAC__" and event.CanVeto():
self.Iconize(True)
self.Hide()
event.Veto()
else:
self.OnCloseWindow(event) # This function
also calls destroy
Nothing seems to match all three conditions.
Thanks in advance,
Roee.
I don't do the exact same thing that you're talking about, but it's quite
similar (although I use Windows XP and I actually minimize to the tray).
Also, when I create my application, I have the icon already created.
However, I would think you could catch the EVT_CLOSE and do the icon
creation then. So something like this *untested* code:
<code>
self.Bind(wx.EVT_CLOSE, self.onClose)
def onClose(self, event):
# I'm not sure if this IF of yours will work or not...
if wx.Platform == "__WXMAC__" and event.CanVeto():
# create icon from the Demo
self.tbicon = TaskBarIcon(self.frame, self.iconfilepath)
self.Hide()
</code>
Then in the TaskbarIcon code, you'd want to edit the "CreatePopupMenu()"
method to have the appropriate menu items. Basically something like this:
<code>
menu = wx.Menu()
menu.Append(self.TBMENU_RESTORE, "Show Application")
</code>
Hopefully that isn't completely confusing.
Mike
···
-----Original Message-----