Python objc.YES Examples
The following are 5
code examples of objc.YES().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
objc
, or try the search function
.
Example #1
Source File: wrp.py From wrp with Apache License 2.0 | 6 votes |
def getURL(self, webview): req = REQ.get() WebkitLoad.httpout = req[0] WebkitLoad.req_url = req[1] WebkitLoad.req_img = req[2] WebkitLoad.req_map = req[3] if WebkitLoad.req_url == "http://wrp.stop/" or WebkitLoad.req_url == "http://www.wrp.stop/": print ">>> Terminate Request Received" AppKit.NSApplication.sharedApplication().terminate_(None) nsurl = Foundation.NSURL.URLWithString_(WebkitLoad.req_url) if not (nsurl and nsurl.scheme()): nsurl = Foundation.NSURL.alloc().initFileURLWithPath_(WebkitLoad.req_url) nsurl = nsurl.absoluteURL() Foundation.NSURLRequest.setAllowsAnyHTTPSCertificate_forHost_(objc.YES, nsurl.host()) self.resetWebview(webview) webview.mainFrame().loadRequest_(Foundation.NSURLRequest.requestWithURL_(nsurl)) if not webview.mainFrame().provisionalDataSource(): print " ... not a proper url?" RESP.put('') self.getURL(webview)
Example #2
Source File: webkit2png.py From wrp with Apache License 2.0 | 5 votes |
def getURL(self, webview): if self.urls: if self.urls[0] == '-': url = sys.stdin.readline().rstrip() if not url: AppKit.NSApplication.sharedApplication().terminate_(None) else: url = self.urls.pop(0) else: AppKit.NSApplication.sharedApplication().terminate_(None) nsurl = Foundation.NSURL.URLWithString_(url) if not (nsurl and nsurl.scheme()): nsurl = Foundation.NSURL.alloc().initFileURLWithPath_(url) nsurl = nsurl.absoluteURL() if self.options.ignore_ssl_check: Foundation.NSURLRequest.setAllowsAnyHTTPSCertificate_forHost_(objc.YES, nsurl.host()) print "Fetching", nsurl, "..." self.resetWebview(webview) scriptobject = webview.windowScriptObject() scriptobject.setValue_forKey_(Webkit2PngScriptBridge.alloc().init(), 'webkit2png') webview.mainFrame().loadRequest_(Foundation.NSURLRequest.requestWithURL_(nsurl)) if not webview.mainFrame().provisionalDataSource(): print " ... not a proper url?" self.getURL(webview)
Example #3
Source File: picidae.py From wrp with Apache License 2.0 | 5 votes |
def saveImages(self,bitmapdata,filename,options): # save the fullsize png if options.fullsize: bitmapdata.representationUsingType_properties_(AppKit.NSPNGFileType,None).writeToFile_atomically_(filename + ".png",objc.YES) if options.thumb or options.clipped: # work out how big the thumbnail is width = bitmapdata.pixelsWide() height = bitmapdata.pixelsHigh() thumbWidth = (width * options.scale) thumbHeight = (height * options.scale) # make the thumbnails in a scratch image scratch = AppKit.NSImage.alloc().initWithSize_( Foundation.NSMakeSize(thumbWidth,thumbHeight)) scratch.lockFocus() AppKit.NSGraphicsContext.currentContext().setImageInterpolation_( AppKit.NSImageInterpolationHigh) thumbRect = Foundation.NSMakeRect(0.0, 0.0, thumbWidth, thumbHeight) clipRect = Foundation.NSMakeRect(0.0, thumbHeight-options.clipheight, options.clipwidth, options.clipheight) bitmapdata.drawInRect_(thumbRect) thumbOutput = AppKit.NSBitmapImageRep.alloc().initWithFocusedViewRect_(thumbRect) clipOutput = AppKit.NSBitmapImageRep.alloc().initWithFocusedViewRect_(clipRect) scratch.unlockFocus() # save the thumbnails as pngs if options.thumb: thumbOutput.representationUsingType_properties_( AppKit.NSPNGFileType,None ).writeToFile_atomically_(filename + "-thumb.png",objc.YES) if options.clipped: clipOutput.representationUsingType_properties_( AppKit.NSPNGFileType,None ).writeToFile_atomically_(filename + "-clipped.png",objc.YES)
Example #4
Source File: webkit2png.py From wrp with Apache License 2.0 | 4 votes |
def saveImages(self, bitmapdata, filename, options): # save the fullsize png if options.fullsize: bitmapdata.representationUsingType_properties_( AppKit.NSPNGFileType, None ).writeToFile_atomically_(filename + "-full.png", objc.YES) if options.thumb or options.clipped: # work out how big the thumbnail is width = bitmapdata.pixelsWide() height = bitmapdata.pixelsHigh() thumbWidth = (width * options.scale) thumbHeight = (height * options.scale) # make the thumbnails in a scratch image scratch = AppKit.NSImage.alloc().initWithSize_( Foundation.NSMakeSize(thumbWidth, thumbHeight)) scratch.lockFocus() AppKit.NSGraphicsContext.currentContext().setImageInterpolation_( AppKit.NSImageInterpolationHigh) thumbRect = Foundation.NSMakeRect(0.0, 0.0, thumbWidth, thumbHeight) clipRect = Foundation.NSMakeRect( 0.0, thumbHeight-options.clipheight, options.clipwidth, options.clipheight) bitmapdata.drawInRect_(thumbRect) thumbOutput = AppKit.NSBitmapImageRep.alloc()\ .initWithFocusedViewRect_(thumbRect) clipOutput = AppKit.NSBitmapImageRep.alloc()\ .initWithFocusedViewRect_(clipRect) scratch.unlockFocus() # save the thumbnails as pngs if options.thumb: thumbOutput.representationUsingType_properties_( AppKit.NSPNGFileType, None).writeToFile_atomically_( filename + "-thumb.png", objc.YES) if options.clipped: clipOutput.representationUsingType_properties_( AppKit.NSPNGFileType, None).writeToFile_atomically_( filename + "-clipped.png", objc.YES)
Example #5
Source File: webrender.py From wrp with Apache License 2.0 | 4 votes |
def webView_didFinishLoadForFrame_(self,webview,frame): # don't care about subframes if (frame == webview.mainFrame()): view = frame.frameView().documentView() self.resizeWebview(view) URL = frame.dataSource().initialRequest().URL().absoluteString() for fl in glob.glob("webrender-*.gif"): os.remove(fl) GIF = "webrender-%s.gif" % (random.randrange(0,1000)) bitmapdata = self.captureView(view) bitmapdata.representationUsingType_properties_(AppKit.NSGIFFileType,None).writeToFile_atomically_(GIF,objc.YES) myurl = "http://%s:%s%s" % (socket.gethostbyname(socket.gethostname()), os.getenv("SERVER_PORT"), os.getenv("SCRIPT_NAME")) print "Content-type: text/html\r\n\r\n" print "<!-- webrender.py by Antoni Sawicki -->" print "<html><head><title>Webrender - %s</title></head><body><table border=\"0\"><tr>" % (URL) print "<td><form action=\"%s\">" % (myurl) print "<input type=\"text\" name=\"url\" value=\"%s\" size=\"80\">" % (URL) print "<input type=\"submit\" value=\"go\">" print "</form></td><td>" print "<form action=\"%s\">" % (myurl) print "<input type=\"text\" name=\"search\" value=\"\" size=\"20\">" print "<input type=\"submit\" value=\"search\">" print "</form></td></tr></table>" print "<img src=\"../%s\" alt=\"webrender\" usemap=\"#map\" border=\"0\">" % (GIF) # Analyse HTML and get links print "<map name=\"map\">"; domdocument = frame.DOMDocument() domnodelist = domdocument.getElementsByTagName_('A') i = 0 while i < domnodelist.length(): # linkvalue value = domnodelist.item_(i).valueForKey_('href') # position-rect myrect = domnodelist.item_(i).boundingBox() xmin = Foundation.NSMinX(myrect) ymin = Foundation.NSMinY(myrect) xmax = Foundation.NSMaxX(myrect) ymax = Foundation.NSMaxY(myrect) # print Link escval = string.replace( string.replace(value, "?", "TNXQUE"), "&", "TNXAMP" ) print "<area shape=\"rect\" coords=\"%i,%i,%i,%i\" alt=\"\" href=\"%s?url=%s\"></area>" % (xmin, ymin, xmax, ymax, myurl, escval) i += 1 print "</map>" print "</body></html>" self.getURL(webview)