def map(self): uiuc_coords = [40.1100, -88.2272] my_map = folium.Map(location=uiuc_coords, zoom_start=18) my_map.add_child(folium.ClickForMarker()) html = my_map.get_root().render() html = html.encode("utf-8", "replace") b64 = base64.b64encode(html).decode("utf-8", "replace") url = "data:text/html;base64,{data}".format(data=b64) self.add_widget(CEFBrowser(url=url))
def __init__(self, urls=["http://www.rentouch.ch"], *largs, **dargs): super(TabbedCEFBrowser, self).__init__(cols=1, *largs, **dargs) gl = GridLayout(rows=1, size_hint=(1, None), height=controls_size) self.current_tab = None self.__tab_bar_scroll = ScrollView(size_hint=(1, 1)) self.__tab_bar_grid = GridLayout(rows=1, size_hint=(None, 1)) self.__tab_bar_grid.bind( minimum_width=self.__tab_bar_grid.setter("width")) last_tab = None for url in urls: this_tab = TabbedCEFBrowserTab(self, url, url) this_tab.last_tab = last_tab self.__tab_bar_grid.add_widget(this_tab) last_tab = this_tab self.current_tab = last_tab self.__tab_bar_scroll.add_widget(self.__tab_bar_grid) self.__tab_bar_scroll.bind(height=self.__tab_bar_grid.setter("height")) gl.add_widget(self.__tab_bar_scroll) self.__tab_bar_new = Button(text="+", font_size=controls_size / 2, size_hint=(None, 1), width=controls_size) self.__tab_bar_new.bind(on_press=self._on_new_tab) gl.add_widget(self.__tab_bar_new) self.__control_bar_grid = GridLayout(rows=1, size_hint=(1, None), height=controls_size) self._back_button = Button(text="<", font_size=controls_size / 2, size_hint=(None, 1), width=controls_size) self._back_button.bind(on_press=self._on_back_press) self._forward_button = Button(text=">", font_size=controls_size / 2, size_hint=(None, 1), width=controls_size) self._forward_button.bind(on_press=self._on_forward_press) self._url_input = TextInput(text="http://", font_size=controls_size / 2, size_hint=(1, 1), multiline=False) self._url_input.bind(focus=self._on_url_focus) self._url_input.bind(on_text_validate=self._on_url_validate) self._load_button = Button(text="Go", font_size=controls_size / 2, size_hint=(None, 1), width=controls_size) self._load_button.bind(on_press=self._on_load_button) self.__control_bar_grid.add_widget(self._back_button) self.__control_bar_grid.add_widget(self._forward_button) self.__control_bar_grid.add_widget(self._url_input) self.__control_bar_grid.add_widget(self._load_button) self._current_browser = CEFBrowser() self.add_widget(gl) self.add_widget(self.__control_bar_grid) self.add_widget(self._current_browser) self.select_first_tab()
def build(self): # Set runtime data paths CEFBrowser.set_data_path(os.path.realpath("./cef_data")) # CEFBrowser.set_caches_path(os.path.realpath("./cef_caches")) # CEFBrowser.set_cookies_path(os.path.realpath("./cef_cookies")) # CEFBrowser.set_logs_path(os.path.realpath("./cef_logs")) Logger.info("Example: The CEF pathes have been set to") Logger.info("- Cache %s", CEFBrowser._caches_path) Logger.info("- Cookies %s", CEFBrowser._cookies_path) Logger.info("- Logs %s", CEFBrowser._logs_path) # Create CEFBrowser instance. Go to test-site. cb = CEFBrowser(url="http://jegger.ch/datapool/app/test.html") return cb
def build(self): return CEFBrowser( url="http://jegger.ch/datapool/app/test_input.html")
def cef_browser(self): if not self.__cef_browser: self.__cef_browser = CEFBrowser(self.url) self.__configure_cef_browser() return self.__cef_browser
def build(self): layout = AnchorLayout(padding=(50, 50)) browser = CEFBrowser(url="http://html5demos.com/drag") layout.add_widget(browser) return layout
def build(self): return CEFBrowser(url="https://www.vsynctester.com")
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Example of the CEFBrowser widget communicating to JavaScript in its Browser. """ from kivy.app import App from cefbrowser import CEFBrowser if __name__ == '__main__': # Create CEFBrowser instance. Go to JS binding test-site. cb = CEFBrowser(url="http://jegger.ch/datapool/app/test_js_bind.html") # Define upcall (JS to Python) callback def callback(*largs): print("callback in Python from JS", largs) cb.js.bind(test_upcall=callback) # Do the downcall (Python to JS) as soon as site is loaded. # The downcall will trigger the upcall on the test-site. def do_downcall(*largs): cb.js.test_downcall("test", 3) cb.bind(on_load_end=do_downcall) # Start the kivy App class JSBindBrowserApp(App): def build(self): return cb
filePath = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data', *filePathComponents) if not os.path.isfile(filePath): self.send_response(404) self.end_headers() return self.send_response(200) self.end_headers() self.wfile.write(open(filePath, 'rb').read()) httpd = HTTPServer(('', 8081), RequestHandler) threading.Thread(target=httpd.serve_forever, args=()).start() print("http://localhost:8081/general.html") cb = CEFBrowser(url="http://localhost:8081/general.html") # cb._browser.ShowDevTools() # Define upcall (JS to Python) callback def test_result(res, exp, ident, desc, *largs): print("callback in Python from JS", exp, ident, desc, largs) def th(*largs): if ident == "focus": time.sleep(1) elif ident[:11] == "input_type_": time.sleep(0.5) else: time.sleep(0.1) if ident == "alert":