[Pythonmac-SIG] Menus for wxPythonMac

Kevin Ollivier kevino@tulane.edu
Thu, 10 Jan 2002 23:44:38 -0500


> That's quite a hairy issue.  You see, the way WindowServer and the Dock
> work, to my knowledge, is that they just *will not* register two
> separate dock instances or two menus for the same pid.
>
> It is possible to change the menu bars dynamically, so, with appropriate
> fixes to wxWindows and/or wxPython's source code it could work by using
> submenus or something under PythonInterpreter.  But until apple (which
> they will almost certainly never do...) properly documents WindowServer
> and the behind-the-scenes stuff that goes on it's going to be pretty
> difficult to see flawless operation of any scripting language with the
> GUI.

I don't think this will be too much work using wxWindows, in fact, what
confuses me is that (as I understand it) wxWindows is actually built to
dynamically create and change menus on Mac. This is because wxWindows apps
generally define menu items right inside the code. To me this indicates that
there is some problem with wxWindows getting 'access' to the hosting
application's menubar.

My (Mac-inexperienced) eyes see two possible problems:

1. A resource file conflict? This seems rather unlikely to me, but I noticed
that most Mac apps use an 'MBAR' resource to define their menus. Could it
cause a problem if a shared library and the 'host' application both define a
MBAR resource, especially if they have the same resource ID? Also, would
anyone know if a shared library needs its resource file bundled with the
hosting application or is it compiled into the library? If this is the case,
creating a wxWindows version of the Python app could solve this problem.

2. GetNewMBar() fails because a menubar already exists for the application.
This seems more likely to me, the question then becomes: is there a way to
check to see if a menubar exists before calling GetNewMBar(), and if so,
getting the Handle to that menubar? Does my thinking make sense here?

Of course, I'm new to Mac programming so I may be missing something obvious
here. ^_^;

Thanks for your help!

Kevin

> The only solution I can think of is to make dummy application bundles
> and launch them in separate processes, and have some sort of socket
> communication between wxPython and the dummy bundles.  Each bundle would
> have to have a unique name because WindowServer seems to use argv[0] as
> it's key to redirect events back to the application, so it could get
> confused.  This is a terrible hack, but it would almost certainly work.
> The problem is that all communication to windows probably has to be done
> over sockets, unless you can get an NSApplication pointer to the dummy
> app or something, which would be awfully cool.  It'd be a lot of work
> though, obviously.
>
> -bob
>
> On Sunday, January 6, 2002, at 04:22 PM, Kevin & Masako Ollivier wrote:
>
> > Sorry for the cross-posting, but I thought I'd cover all my bases! =)
> >
> > I'll briefly explain where I'm at. I'm using the Carbon version of
> > Python
> > 2.2, along with wxWindows and wxPython on OS X 10.1.2. I've pulled all
> > the
> > sources from CVS. Everything compiles, and so far I've been able to run
> > wxPython scripts with a limited degree of success. However, the major
> > problem is that I'm still having troubles with the menus. When I load a
> > wxPython script in Python, Python's menubars stay active and the menus
> > created by the script are nowhere to be found. Has anyone else
> > experienced
> > this?
> >
> > Also, when I run the script it does not open as a separate application
> > in OS
> > X. All windows are listed as child windows of the Python application.
> > I'm
> > wondering if these two issues are related. wxPython may not be able to
> > modify Python's menus, and since it does not have its own application,
> > it
> > has no way of showing its own menus. Does this make sense? I admit I'm
> > pretty new to Mac programming, and as such I'm a bit stuck as to what
> > can be
> > done about this problem. Any help would be appreciated!
> >
> > Thanks,
> >
> > Kevin
> >
> >
> >
> >
> > _______________________________________________
> > Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> > http://mail.python.org/mailman/listinfo/pythonmac-sig
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>