def awakeFromNib(self): self.openImageIOSupportedTypes = None # Ask CFBundle for the location of our demo image url = Cocoa.CFBundleCopyResourceURL(Cocoa.CFBundleGetMainBundle(), u"demo", u"png", None) if url is not None: # And if available, load it self.imageView.setImage_(CGImageUtils.IICreateImage(url)) self.imageView.window().center() self.setRotation_(0.0) self.setScaleX_(1.0) self.setScaleY_(1.0) self.setTranslateX_(0.0) self.setTranslateY_(0.0) self.setPreserveAspectRatio_(False)
def doDrawImageFile(context, doclip): global _ourImageURL if _ourImageURL is None: mainBundle = Cocoa.CFBundleGetMainBundle() if mainBundle: _ourImageURL = Cocoa.CFBundleCopyResourceURL( mainBundle, kOurImageFile, None, None) else: print("Can't get the app bundle!") if _ourImageURL: if doclip: clipImageToEllipse(context, _ourImageURL) else: drawCGImage(context, _ourImageURL) else: print("Couldn't create the URL for our Image file!")
def GetURL(name): """ Returns the CFURLRef for an embeded resource, or None of that cannot be found. """ global _mainBundle if _mainBundle is None: _mainBundle = Utilities.getAppBundle() mainBundle = _mainBundle if mainBundle is not None: if name in _urlMap: return _urlMap[name] url = Cocoa.CFBundleCopyResourceURL(mainBundle, name, None, None) _urlMap[name] = url else: print("Can't get the app bundle!") return if url is None: print("Couldn't get URL for %r" % (name, )) return url