def title(self, title): '''Set the title. ''' if isinstance(title, NSStr): try: self.NS.setTitle_(title) except AttributeError: # no NSApplication.setTitle_ pass title = nsString2str(title) else: try: t = NSStr(title) self.NS.setTitle_(t) release(t) except AttributeError: # no NSApplication.setTitle_ t.release() self._title = bytes2str(title)
def open(self, url, tab=False): '''Open a new window or tab in the browser. @param url: The URL to open (C{str}). @keyword tab: New tab (C{bool}), new window otherwise. @return: Parsed I{url} as C{ParseResult}. @raise ValueError: Scheme of I{url} not 'http', 'https' or 'file'. ''' ns = url2NS(url) sc = nsString2str(ns.scheme()) if sc.lower() not in ('http', 'https', 'file'): raise ValueError('%s scheme %r invalid: %r' % ('url', sc, url)) if self._browser: self._browser.open(url, new=2 if tab else 1) elif self.NS: d = dict2NS(dict(URL=ns, reveal=True, newTab=bool(tab)), frozen=True) u = NSStr('WebBrowserOpenURLNotification') self.NS.postNotificationName_object_userInfo_(u, None, d) u.release() # PYCHOK expected return _urlparse(nsString2str(ns.absoluteString()))
def _nsFontsOf(family): t = NSStr(family) r = NSMain.FontManager.availableMembersOfFontFamily_(t) t.release() # PYCHOK expected return r