def set_url(self, value): if value: if self.interface.url.startswith('file://'): url = NSURL.fileURLWithPath(self.interface.url[7:]) else: url = NSURL.URLWithString(self.interface.url) request = NSURLRequest.requestWithURL_(url) self.native.loadRequest_(request)
def load_image(self, path): # If a remote URL is provided, use the download from NSData (similar to toga-cocoa) if path.startswith('http://') or path.startswith('https://'): self.native = UIImage.imageWithData_( NSData.dataWithContentsOfURL_(NSURL.URLWithString_(path))) else: self.native = UIImage.alloc().initWithContentsOfFile_( self.__get_full_path(path))
def __init__(self, interface, path=None, url=None): self.interface = interface self.path = path self.url = url if path: self.native = UIImage.alloc().initWithContentsOfFile_(str(path)) elif url: # If a remote URL is provided, use the download from NSData self.native = UIImage.imageWithData_( NSData.dataWithContentsOfURL_(NSURL.URLWithString_(path)))
def set_content(self, root_url, content): self.native.loadHTMLString_baseURL_(content, NSURL.URLWithString_(root_url))
def set_url(self, value): if value: request = NSURLRequest.requestWithURL_(NSURL.URLWithString_(self.interface.url)) self.native.loadRequest_(request)