Macs are experiencing extensive growth these days, and the Mac App Store is clearly a great tool for software developers who wish to sell their software to the world. So more than ever, it’s important that whatever tool you use to create Mac software can make a “good Mac citizen.”
So is wx, specifically wxPython, up to the task? This series of blog entries will attempt to chronicle my attempts to find out.
Let’s start with first things first. The “no window” app. On Mac, an app can have no windows open, but have a menubar, so you can say, create a document. Some start that way, although most don’t. Can wx handle this? Let’s test the 18.104.22.168 OS X Cocoa build and find out.
The answer is, sort of. You can create an app that has an app-level menu bar and set the wx.App to handle events on it, and by calling SetExitsOnFrameDelete(False) on the app, you can keep the app alive even if all top level frames are closed / destroyed. However, what you can’t do is NOT create a frame when initializing the app. Even if SetExitsOnFrameDelete(False) is called, if during initialization there is no frame, the app will still shut down. Here is some sample code that exhibits this:
NewFrameAction = wx.NewId()
self.Bind(wx.EVT_MENU, self.OnNewFrame, id=NewFrameAction)
def OnNewFrame(self, event):
frame = wx.Frame(None, -1, “Test Frame”)
class MyApp(wx.PySimpleApp, MyAppDelegate):
file_menu = wx.Menu()
file_menu.Append(NewFrameAction, “New Frame”)
menu_bar = wx.MenuBar()
app = MyApp()