[Pythonmac-SIG] wxPython for OS X - now with menus!

Kevin & Masako Ollivier guess-who@kevin-masako.com
Tue, 15 Jan 2002 21:07:31 -0500


Hi everyone,

I've (finally!) been able to get menus working on wxPython for Mac OS X. =)
Of course, I did not forget the obligatory screenshot:

http://payson.tulane.edu/kollivier/wxPythonMac-menu.JPG

I tested a number of samples out (including demo.py, hangman.py,
slashdot.py, and wxProject.py) and all the menu code ran fine. There was one
time where there did not appear to be any space between a menu title text
and the shortcut key, but that was the only issue I encountered.

So how did I do it? Actually, all I did was remove a few lines from the
wxWindows/wxMac source code which read in the menubar resource. Here's the
code I removed:

File: src/mac/menu.cpp
in Function wxMenuBar::MacInstallMenuBar

Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
wxString message ;
wxCHECK_RET( menubar != NULL, wxT("can't read MBAR resource"));
::SetMenuBar( menubar ) ;
::DisposeHandle( menubar ) ;

Feel free to try this at home! I'm sure this will cause problems when
creating compiled apps on OS X though. My question is: is there a place we
can "move" the menubar initialization code so that it will get run by
compiled applications, but not by scripted apps? Maybe add an
"InitMenuBar()" function into the IMPLEMENT_APP macro for Mac?

Once we get this code issue resolved, I'm thinking we may want to build an
"alpha" binary version of wxPython for Mac, so that people can play with it
and see what has been done so far. What do you think? A majority of the
other issues I've found in the samples are simply visual "glitches" (like
text alignment and control overlap issues) that should have a more
straight-forward fix for them. =)

Thanks,

Kevin