def set_css(self, css_str: str, base_url: str, media_type: str): """Set (reset) style sheet of current document.""" utf = css_str.encode('utf-8') ok = _api.SciterSetCSS(self.hwnd, utf, len(utf), base_url, media_type) if not ok: raise sciter.SciterError("Could not set CSS") return self
def set_media_vars(self, media: dict): """Set media variables of this sciter instance.""" v = sciter.Value(media) ok = _api.SciterSetMediaVars(self.hwnd, v) if not ok: raise sciter.SciterError("Could not set media vars " + str(media)) return self
def set_media_type(self, media_type: str): """Set media type of this sciter instance.""" ok = _api.SciterSetMediaType(self.hwnd, media_type) if not ok: raise sciter.SciterError("Could not set media type " + str(media_type)) return self
def load_file(self, uri: str, normalize=True): """Load HTML document from file.""" if normalize and "://" not in uri: uri = "file://" + os.path.abspath(uri).replace("\\", "/") ok = _api.SciterLoadFile(self.hwnd, uri) if not ok: raise sciter.SciterError("Unable to load file " + uri) self.root = self.get_root() return self
def set_master_css(self, css_str: str, append: bool): """Set Master style sheet.""" utf = css_str.encode('utf-8') if append: ok = _api.SciterAppendMasterCSS(utf, len(utf)) else: ok = _api.SciterSetMasterCSS(utf, len(utf)) if not ok: raise sciter.SciterError("Could not set master CSS") return self
def setup_debug(self, hwnd=None): """Setup debug output function for specific window or globally.""" ok = _api.SciterSetOption(hwnd, SCITER_RT_OPTIONS.SCITER_SET_DEBUG_MODE, True) if not ok: raise sciter.SciterError("Could not set debug mode") self._sciter_debug_proc = DEBUG_OUTPUT_PROC(self.on_debug_output) _api.SciterSetupDebugOutput(hwnd, None, self._sciter_debug_proc) pass
def load_html(self, html: bytes, uri=None): """Load HTML document from memory.""" if not isinstance(html, bytes): raise TypeError("html must be a bytes type") cb = len(html) pb = ctypes.c_char_p(html) ok = _api.SciterLoadHtml(self.hwnd, pb, cb, uri) if not ok: raise sciter.SciterError("Unable to load html " + str(uri)) self.root = self.get_root() return self
def set_option(self, option, value): """Set various sciter engine options, see the SCITER_RT_OPTIONS.""" hwnd = self.hwnd if option in (SCITER_RT_OPTIONS.SCITER_SET_GPU_BLACKLIST, SCITER_RT_OPTIONS.SCITER_SET_GFX_LAYER, SCITER_RT_OPTIONS.SCITER_SET_UX_THEMING): hwnd = None ok = _api.SciterSetOption(hwnd, option, value) if not ok: raise sciter.SciterError("Could not set option " + str(option) + "=" + str(value)) return self
def data_ready(self, uri: str, data: bytes, request_id=None, hwnd=None): """This function is used as response to SCN_LOAD_DATA request.""" if not hwnd: hwnd = self.hwnd if request_id is not None: ok = _api.SciterDataReadyAsync(hwnd, uri, data, len(data), request_id) else: ok = _api.SciterDataReady(hwnd, uri, data, len(data)) if not ok: raise sciter.SciterError("Unable to pass data for " + uri) pass
def set_home_url(self, url: str): """Set sciter window home url.""" ok = _api.SciterSetHomeURL(self.hwnd, url) if not ok: raise sciter.SciterError("Could not set home url " + str(url)) return self