def start(): email = refresh.Email("*****@*****.**", "password") email.login() email.get_new_emails() email.say() x = a.listen() while True: if x == "help": a.say( "read, to read out your unread emails, new, to compose a new email, refresh, to refresh your inbox, close, to close the app" ) elif x == "read": reademails.read(email.body, email.subject, email.sender, email.user, email.passw) elif x == "new": compose.compos(f=email.user, p=email.passw) elif x == "@#": a.say("i didnt catch that, could you repeat it") elif x == "close": webview.destroy_window() email.close() exit() elif x == "refresh" or "reference": email.get_new_emails() email.say() else: a.say("say a valid command") x = '' x = a.listen()
def destroy(): # show the window for a few seconds before destroying it: time.sleep(5) print("Destroying window..") webview.destroy_window() print("Destroyed!")
def load_html(): child_window = webview.create_window('Window #2') assert child_window != 'MainWindow' webview.load_html( '<body style="background: red;"><h1>Master Window</h1></body>', uid=child_window) webview.destroy_window(child_window)
def evaluate_js(): child_window = webview.create_window('Window #2', 'https://google.com') assert child_window != 'MainWindow' result1 = webview.evaluate_js(""" document.body.style.backgroundColor = '#212121'; // comment function test() { return 2 + 5; } test(); """) assert result1 == 7 result2 = webview.evaluate_js(""" document.body.style.backgroundColor = '#212121'; // comment function test() { return 2 + 2; } test(); """, uid=child_window) assert result2 == 4 webview.destroy_window(child_window)
def destroy(): # show the window for a few seconds before destroying it: time.sleep(5) print("Destroying window..") webview.destroy_window() print("Destroyed!")
def stop(): event.wait() time.sleep(delay) webview.destroy_window() if sys.platform == 'darwin': from .util_cocoa import mouseMoveRelative mouseMoveRelative(1, 1)
def _js_bridge(webview): webview.load_html('<html><body><h1>Master window</h1></body></html>') api2 = Api2() child_window = webview.create_window('Window #2', js_api=api2) webview.load_html('<html><body><h1>Secondary window</h1></body></html>', uid=child_window) assert_js(webview, 'test1', 1) assert_js(webview, 'test2', 2, uid=child_window) webview.destroy_window(child_window) destroy_event.set()
def js_bridge(): class Api2: def test2(self, params): return 2 webview.load_html('<html><body><h1>Master window</h1></body></html>') api2 = Api2() child_window = webview.create_window('Window #2', js_api=api2) assert child_window != 'MainWindow' webview.load_html('<html><body><h1>Secondary window</h1></body></html>', uid=child_window) assert_js(webview, 'test1', 1) assert_js(webview, 'test2', 2, uid=child_window) webview.destroy_window(child_window)
def show_carrousel(): time.sleep(5) while True: script = [line.rstrip('\n') for line in open('carrousel1.txt')] for line in script: if (line == "quit"): webview.destroy_window() sys.exit(0) try: page,timeout=line.split(',') print page webview.load_url(page) time.sleep(int(timeout)) except: print "ERROR:",line
def js_bridge(): class Api2: def test2(self, params): return 2 webview.load_html('<html><body><h1>Master window</h1></body></html>') api2 = Api2() child_window = webview.create_window('Window #2', js_api=api2) assert child_window != 'MainWindow' webview.load_html('<html><body><h1>Secondary window</h1></body></html>', uid=child_window) assert_js(webview, 'test1', 1) assert_js(webview, 'test2', 2, uid=child_window) webview.destroy_window(child_window)
def run_view(url, stop_event): """ this should be in it's own thread :param url:string :param stop_event: threading.Event, triggered when shutdown time happens :return: None """ logger.info("waiting for webserver to start...") block_until_server_started(url) logger.info("starting view...") webview.create_window(title="Simple Mod Installer", url=url) # the window has been closed, lets shut down logger.info("View closed, shutting down...") webview.destroy_window() stop_event.set()
def get_cookies(): timeout = 120 def is_logged_in(): return webview.evaluate_js( "document.querySelector('#logout-btn') !== null") while not webview.webview_ready() or not is_logged_in(): time.sleep(1) timeout -= 1 if timeout == 0: raise AuthenticationFailed("Can't login, timeout exceeded.") if not webview.window_exists(): raise AuthenticationFailed( "Webview window closed prematurely.") cookies = webview.evaluate_js("document.cookie") webview.destroy_window() return cookies
def evaluate_js(): child_window = webview.create_window('Window #2', 'https://google.com') assert child_window != 'MainWindow' result1 = webview.evaluate_js(""" document.body.style.backgroundColor = '#212121'; // comment function test() { return 2 + 5; } test(); """) assert result1 == 7 result2 = webview.evaluate_js(""" document.body.style.backgroundColor = '#212121'; // comment function test() { return 2 + 2; } test(); """, uid=child_window) assert result2 == 4 webview.destroy_window(child_window)
def on_stackoverflow(data): if data["devHand"] == True: try: webview.destroy_window() except Exception: pass print("Received StackOverflow question:", data["query"]) #webbrowser.open(data["link"]) with open("style.css") as css_file: css = css_file.read() html = f"""<!DOCTYPE html> <html> <head> <title>{data['query']}</title> <style> {css} </style> </head> <body> <div id="answer"> <h3 style="answer-heading">BEST ANSWER ({data['score']})</h3> {data['html']} </div> </body> </html> """ def load_html(): webview.load_html(html) t = threading.Thread(target=load_html) t.start() webview.create_window(data["query"], width=500, height=700)
def destroy(): import time time.sleep(5) print("Destroying window..") webview.destroy_window()
def quit(self, arg): # until i find a better way webview.destroy_window()
def displayTab(self): self.close() webview.destroy_window() views = DisplayB() views.show() views.exec_()
def _bg_color(webview): child_window = webview.create_window('Window #2', background_color='#0000FF') webview.webview_ready() webview.destroy_window(child_window) destroy_event.set()
def _load_url(webview): child_window = webview.create_window('Window #2') webview.load_url('https://google.com', uid=child_window) webview.destroy_window(child_window) destroy_event.set()
def signal_handler(signal, frame): log.info('You pressed Ctrl+C!') webview.destroy_window() sys.exit(0)
def close_message_listener(receiver): close = receiver.recv() if close: webview.destroy_window() print('窗口 close')
def navtomov(self): self.close() webview.destroy_window() newvar = mplayer() newvar.exec_()
def load_url(): child_window = webview.create_window('Window #2') assert child_window != 'MainWindow' webview.load_url('https://google.com', uid=child_window) webview.destroy_window(child_window)
def load_html(): child_window = webview.create_window('Window #2') assert child_window != 'MainWindow' webview.load_html('<body style="background: red;"><h1>Master Window</h1></body>', uid=child_window) webview.destroy_window(child_window)
def quit(): """docstring for quit""" webview.destroy_window() return jsonify({})
def close_down(): response = {'message': 'closing'} webview.destroy_window() os._exit(0) return jsonify(response)
def stop(self): webview.destroy_window()
def destroy(): import time time.sleep(5) print("Destroying window..") webview.destroy_window() print("Destroyed!")
def close(self): webview.destroy_window()
def bg_color(): child_window = webview.create_window('Window #2', background_color='#0000FF') assert child_window != 'MainWindow' webview.webview_ready() webview.destroy_window(child_window)
def on_execute(self, *args): global commands commands += args socketio_client.disconnect() socketio.stop() webview.destroy_window()
def load_url(): child_window = webview.create_window('Window #2') assert child_window != 'MainWindow' webview.load_url('https://google.com', uid=child_window) webview.destroy_window(child_window)
def bg_color(): child_window = webview.create_window('Window #2', background_color='#0000FF') assert child_window != 'MainWindow' webview.webview_ready() webview.destroy_window(child_window)
def _load_html(webview): child_window = webview.create_window('Window #2') webview.load_html('<body style="background: red;"><h1>Master Window</h1></body>', uid=child_window) webview.destroy_window(child_window) destroy_event.set()
def close(self): """ Destroy a web view window """ webview.destroy_window()