Ejemplo n.º 1
0
    def _initialize(self, gui, multiprocessing, http_server):
        self.gui = gui
        self.loaded._initialize(multiprocessing)
        self.shown._initialize(multiprocessing)

        if http_server and self.url and self.url.startswith('file://'):
            self.url, self._httpd = start_server(self.url)
Ejemplo n.º 2
0
        def load_url(self, url):
            self.ishtml = False

            # WebViewControl as of 5.1.1 crashes on file:// urls. Stupid workaround to make it work
            if url.startswith('file://'):
                url = start_server(self.url)

            self.web_view.Navigate(url)
Ejemplo n.º 3
0
        def load_html(self, html, base_uri):
            self.tmpdir = tempfile.mkdtemp()
            self.temp_html = os.path.join(self.tmpdir, 'index.html')

            with open(self.temp_html, 'w', encoding='utf-8') as f:
                f.write(inject_base_uri(html, base_uri))

            if self.httpd:
                self.httpd.shutdown()

            url, _ = start_server('file://' + self.temp_html)
            self.ishtml = True
            self.web_view.Navigate(url)
Ejemplo n.º 4
0
    def load_url(self, url):
        """
        Load a new URL into a previously created WebView window. This function must be invoked after WebView windows is
        created with create_window(). Otherwise an exception is thrown.
        :param url: url to load
        :param uid: uid of the target instance
        """
        if self._httpd:
            self._httpd.shutdown()
            self._httpd = None

        url = transform_url(url)

        if (self._httpd or self.gui.renderer == 'edgehtml') and url.startswith('file://'):
            url, self._httpd = start_server(url)

        self.gui.load_url(url, self.uid)