FROM : Bill Bumgarner
DATE : Wed Nov 07 08:58:29 2007
On Nov 6, 2007, at 11:49 PM, Uliano Guerrini wrote:
> with every Xcode project template involving Python it is enough to
> add an
>
> import Quartz
>
> to any python file to hang the application with the icon jumping in
> the dock.
> From logs on the console it seems that the application isn't able to
> connect to the window server
.... error messages deleted ....
Python's "import" works quite a bit differently than Objective-C's
#import. Namely, it will execute any code found in the imported
modules that appears within the module's scope.
The Quartz module requires a viable window server connection to be set
up. If you import Quartz in main.py or at the top level of your
application delegate source file (or anywhere that is imported as a
part of the app launching process prior to control being passed to the
appkit), it'll blow up as you have seen.
Instead, import Quartz in response to application initialization. I
dropped "import Quartz" into the standard Cocoa Python Application's
applicationDidFinishLaunching_() method and it no longer bombs (I
didn't test much further than that):
class FoobarAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
import Quartz
NSLog("Application did finish launching.")
b.bum
DATE : Wed Nov 07 08:58:29 2007
On Nov 6, 2007, at 11:49 PM, Uliano Guerrini wrote:
> with every Xcode project template involving Python it is enough to
> add an
>
> import Quartz
>
> to any python file to hang the application with the icon jumping in
> the dock.
> From logs on the console it seems that the application isn't able to
> connect to the window server
.... error messages deleted ....
Python's "import" works quite a bit differently than Objective-C's
#import. Namely, it will execute any code found in the imported
modules that appears within the module's scope.
The Quartz module requires a viable window server connection to be set
up. If you import Quartz in main.py or at the top level of your
application delegate source file (or anywhere that is imported as a
part of the app launching process prior to control being passed to the
appkit), it'll blow up as you have seen.
Instead, import Quartz in response to application initialization. I
dropped "import Quartz" into the standard Cocoa Python Application's
applicationDidFinishLaunching_() method and it no longer bombs (I
didn't test much further than that):
class FoobarAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
import Quartz
NSLog("Application did finish launching.")
b.bum
| Related mails | Author | Date |
|---|---|---|
| Uliano Guerrini | Nov 7, 08:49 | |
| Bill Bumgarner | Nov 7, 08:58 | |
| Uliano Guerrini | Nov 7, 09:46 | |
| Bill Bumgarner | Nov 7, 09:57 | |
| Uliano Guerrini | Nov 7, 10:41 | |
| Bill Bumgarner | Nov 7, 17:48 | |
| Uliano Guerrini | Nov 7, 18:04 | |
| Bill Bumgarner | Nov 7, 18:46 | |
| Luc Heinrich | Nov 8, 09:32 | |
| Uliano Guerrini | Nov 8, 13:00 | |
| Luc Heinrich | Nov 8, 14:10 | |
| Uliano Guerrini | Nov 8, 14:41 |






Cocoa mail archive

