• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Python broken in Leopard??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Python broken in Leopard??


  • Subject: Re: Cocoa Python broken in Leopard??
  • From: Uliano Guerrini <email@hidden>
  • Date: Wed, 7 Nov 2007 09:46:29 +0100


Il giorno 07/nov/07, alle ore 08:58, Bill Bumgarner ha scritto:

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

the problem arises when you want to use Quartz "somewhere" to do something useful and this "somewhere" is likely to be some subclass of NSView (or some file imported in that subclass), well, if I'm not wrong, that subclass in order to work should be imported in the main.py file before


 AppHelper.runEventLoop()

which is the call that fires up the window server

anyway, py2app without aliasing works, in pyobjc-dev they say that they'll find to fix what to them seems a problem to be fixed



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa Python broken in Leopard??
      • From: Bill Bumgarner <email@hidden>
References: 
 >Cocoa Python broken in Leopard?? (From: Uliano Guerrini <email@hidden>)
 >Re: Cocoa Python broken in Leopard?? (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Cocoa Python broken in Leopard??
  • Next by Date: Re: Cocoa Python broken in Leopard??
  • Previous by thread: Re: Cocoa Python broken in Leopard??
  • Next by thread: Re: Cocoa Python broken in Leopard??
  • Index(es):
    • Date
    • Thread