Re: [Pyobjc-dev] Multiple Document App Template
Brought to you by:
ronaldoussoren
From: Jack J. <Jac...@or...> - 2003-01-14 20:58:34
|
I've thought about what you see for a long time, but I can't figure out what is going on, it doesn't make sense. Let me first explain what I thought was going on when Bob mentioned the missing Apple event. My reasoning was that what causes the untitled window to open in an ObjC application is the "open application" event that the finder sends when you double-click the app. If this is the case then your PyObjC application will indeed not open an untitled window, because the "open application" Apple Event will be sent to the stub application which fires up Python, not to Python (and, hence, it will be lost to your PyObjC code). It should be simple to test whether this reasoning is correct: if you start an ObjC application from the Terminal window with ..../xxx.app/Contents/MacOS/xxx it will not open an untitled window. But your findings makes things more complicated. The only thing I can imagine is that NSApplicationMain() looks at argv and if argv isn't the -psn_xxxx magic option it knows it has been started from the command line, and uses argv to construct either an Open Application message (argv empty) or an Open Doc message (argv non-empty). Again, this is easy to test: if it's true then the test above failed (an untitled window was opened), but if you start from the Terminal with a -psn_xxxx option the window will not be opened. And if you pass a filename that file will be opened. On dinsdag, jan 14, 2003, at 17:10 Europe/Amsterdam, Bill Bumgarner wrote: > On Tuesday, Jan 14, 2003, at 10:46 US/Eastern, Bob Ippolito wrote: >> Well the only thing I can think of off the top of my head is that >> there could be some apple event magic happening that causes the new >> untitled document event, and the apple event just isn't being >> handled? > > Damn. Figured it out. Yuck. > > If I add... > > def application_openFile_(self, sender, path): > NSLog("application_openFile_() %s %s" % (sender, path)) > return YES > > ... to the app delegate, this is logged: > > 2003-01-14 10:59:53.731 doctest[17445] application_openFile_() > <NSApplication objective-c instance 0x2c0cb0> > /tmp/bbum-products/doctest.app/Contents/Resources/__main__.py > > In other words, the command line that is passed into python needs to > be massaged before NSApplicationMain() is called. Specifically, the > path to the main.py file needs to be stripped and it needs to be done > from the C side because NSApplicationMain() ignores the argv argument > passed into it. > > Fun, fun. > > Will look into this later today when I have some time... > > b.bum > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: FREE SSL Guide from Thawte > are you planning your Web Server Security? Click here to get a FREE > Thawte SSL guide and find the answers to all your SSL security issues. > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |