示例#1
0
def main():
    # pylint: disable=import-outside-toplevel
    api = Api()
    api.window = webview.create_window(f"Wild Bits {USER_VERSION}",
                                       url=f"{EXEC_DIR}/assets/index.html",
                                       js_api=api)
    gui: str = ""
    if system() == "Windows":
        try:
            # fmt: off
            from cefpython3 import cefpython
            del cefpython
            gui = "cef"
            # fmt: on
        except ImportError:
            pass
    elif system() == "Linux":
        try:
            # fmt: off
            from PyQt5 import QtWebEngine
            del QtWebEngine
            gui = "qt"
            # fmt: on
        except ImportError:
            gui = "gtk"
    webview.start(debug=True,
                  http_server=gui == "",
                  gui=gui,
                  func=api.handle_file)
def start_server():
    retries = 0
    server_started = False

    while not server_started and retries < 100:
        try:
            retries += 1
            list_serial_ports()
            port = get_port()
            server_address = ("127.0.0.1", port)
            httpd = ThreadedHTTPServer(server_address, appRequestHandler)
            threading.Thread(target=httpd.serve_forever).start()
            print(("Server running on port " + str(port)))
            server_started = True

        except Exception as e:
            print("Exception while starting server: " + str(e))
            pass

    webview.create_window('OpenModem Configuration',
                          'http://localhost:' + str(port) + '/',
                          width=575,
                          height=600)
    webview.start()

    os._exit(0)
示例#3
0
def imgdisplay_main():
    imgdisplay_log.debug('Imgdisplay')

    fm = threading.Thread(name='filemon', target=mon.filemonmain, daemon=True)
    fm.start()

    kwargs = {'host': 'localhost', 'port': 5432, 'width': 768, 'height': 432}
    t = threading.Thread(name='start_server',
                         target=start_server,
                         daemon=True,
                         kwargs=kwargs)
    t.start()

    global window
    window = webview.create_window(
        "Live Image View",
        "http://127.0.0.1:{port}".format(port=kwargs['port']),
        height=kwargs['height'],
        width=kwargs['width'],
        fullscreen=False,
        confirm_close=True)

    try:
        imgdisplay_log.debug('WebviewStart')
        webview.start()
    except Exception:
        # logging.exception provides: (1) exception type (2) error message and (3) stacktrace
        imgdisplay_log.exception("Unhandled Exception from Main!")
    except KeyboardInterrupt:
        imgdisplay_log.error("Live View & File Monitoring will be halted!")

    sys.exit()
示例#4
0
 def __init__(self):
     mon = get_monitors()[0]
     window = webview.create_window('',
                                    self.url,
                                    width=mon.width,
                                    height=mon.height)
     webview.start(self.manage, window, gui='cef')
示例#5
0
    def run(self):
        # Webview needs to be run in the MainThread.

        # Prepare for version 2.3 before calling create_window(), which might block forever.
        self.display_window = webview
        # Since webview.create_window might take exclusive and permanent lock on the main thread,
        # we need to start this wait_load function before we start webview itself.
        if "webview_ready" in dir(webview):
            threading.Thread(
                target=lambda: (webview.webview_ready(), load_idle())
            ).start()

        window = webview.create_window(
            title="Jellyfin MPV Shim Mirror", js_api=helpers, fullscreen=True
        )
        if window is not None:
            # It returned a Window object instead of blocking, we're running on 3.2 (or compatible)
            self.display_window = window
            self.webview = window

            # 3.2's .loaded event runs every time a new DOM is loaded as well, so not suitable for this purpose
            # However, 3.2's load_html waits for the DOM to be ready, so we can completely skip
            # waiting for that ourselves.
            threading.Thread(target=load_idle).start()

            webview.start()
示例#6
0
def init():
    global crypto
    key = c.get_val("crypto")
    crypto = OWLCrypto(key)
    c.lock()
    crypto.export()
    # inf = owlapi.get_sys_info()
    # hello_file = filesystem.FSFile("/README.txt",crypto)
    # print(hello_file.read())
    # c.set_val("cpu.clock_speed",inf["clock_speed"])
    print("Mounting FS")
    filesystem.root = filesystem.FSDirectory("",crypto).create()
    print("Done")
    # try:
    #     print(filesystem.root.children[0].path)
    # except Exception as e:
    #     import traceback
    #     print(traceback.print_exception(*sys.exc_info()))
    api = JSInterface(key)
    del key
    t = threading.Thread(target=sandbox_observer_thread)
    t.start()
    signal.signal(signal.SIGINT,await_sigint)
    window = webview.create_window("OWL-OS", url="./index.html", js_api=api)
    # window.toggle_fullscreen()
    webview.start(gui='gtk', debug=True)
示例#7
0
文件: gui.py 项目: obfusk/jiten
def start(link=None, title=title, win_opts=win_opts):
    _fix_profile()

    try:
        import webview
    except ImportError as e:
        if e.name != "webview" or "module named" not in e.msg: raise e
        print(
            "error: failed to load 'webview' module; "
            "to use jiten's gui, please install pywebview",
            file=sys.stderr)
        sys.exit(1)

    os.environ["JITEN_GUI_TOKEN"] = webview.token
    from .app import app

    opts = dict(debug=bool(app.config.get("DEBUG")))
    if system == "Linux" and "PYWEBVIEW_GUI" not in os.environ:
        opts["gui"] = "qt"

    def f():
        if not link: return
        base_url = window.get_current_url().rstrip("/")
        for server in M.SERVERS:
            if link.startswith(server):
                url = link.replace(server, base_url, 1).split("#")[0]
                window.load_url(url)
                break

    window = webview.create_window(title, app, **win_opts)
    webview.start(f, **opts)
示例#8
0
 def __init__(self):
     self.window = webview.create_window("ETAP E-Nahtar",
                                         self.sablonlar.get("varsayilan"),
                                         width=800,
                                         height=600,
                                         fullscreen=True)
     webview.start()
示例#9
0
文件: flair.py 项目: hawbox/Flair
def main():
    global port

    url, max_wait = 'localhost', 15  # 15 seconds
    link = "http://" + url + ":" + str(port)
    # Starting Server
    server_thread = Thread(target=run_app, args=(url, port, False))
    server_thread.daemon = True
    server_thread.start()
    # Waiting for server to load content
    if is_server_running(url, max_wait):
        print("Server started")
        # webbrowser.open(link, new=2)
        # while server_thread.is_alive():
        #     time.sleep(0.1)
        window = webview.create_window("Flair App", link, min_size=(640, 480))
        # If you want to inspect element just go to localhost url in browser
        webview.start(get_user_agent, window)
    else:
        print("Server failed to start with a max wait time of " +
              str(max_wait))
        if status is not False:
            print("Status was " + str(status))
        if error is not False:
            print("Exception was " + str(error))
    print("Server has exited")
示例#10
0
    def main(self, appstore=False):
        """Run the app."""
        # kill possible zombie processes; can't use psutil in py2app context
        system('lsof -nti:' + str(things3_api.Things3API.port) +
               ' | xargs kill -9')

        # Make sure the server shuts down
        signal.signal(signal.SIGTERM, self.sigterm_handler)

        print(f"Using database 1: {self.database}")

        window = webview.create_window(
            title='KanbanView',
            url=f'http://{things3_api.Things3API.host}:' +
            f'{things3_api.Things3API.port}/{self.FILE}',
            width=1280, height=650,
            min_size=(1280, 650),
            frameless=True)
        if not appstore:
            window.closed += advertise
        self.api_thread = Thread(target=self.open_api)

        try:
            self.api_thread.start()
            webview.start()  # blocking
            self.api.flask_context.shutdown()
            self.api_thread.join()
        except KeyboardInterrupt:
            print("Shutting down...")
            self.api.flask_context.shutdown()
            self.api_thread.join()
            sys.exit(0)
示例#11
0
def run(mode="production", web_mode=True):
    print(f"mode: {mode} only_server:")
    port = find_port()
    from app.start_server import start, start_web_client
    start(environment=mode, port=port, is_async=True)
    sleep(3)
    if not web_mode:
        settings = {
            "background_color": '#333333',
            "width": 200, "height": 500,
            "confirm_close": False,
            "resizable": True,
            "frameless": False,
            "easy_drag": False,
            "on_top": True
        }
        def load(window):
            print("window::load", window)
            pass
        # window = Desktop.Instance().new_window(title=TITLE, app=get_app(), settings=settings)
        from app.start_server import get_app
        app = get_app()
        window = webview.create_window(TITLE, app, **settings)
        webview.start(load, window)
    else:
        start_web_client()
示例#12
0
    def upload_test_file(self, event=None):
        filename = filedialog.askopenfilename(initialdir=os.getcwd(),
            title="Select a file You would like to grade: ", filetypes=MY_FILETYPES)
        GraphicUserInterfaces.uploaded_files.append(filename)
        GraphicUserInterfaces.current_file = filename
        with open (filename, 'rt') as file:
            contents = file.read()

        processed = preprocessing(contents)
        generate_wordcloud(processed)
        generate_spelling_graph(contents)
        generate_similarities_graph()
        with open("images/index.html", "wt") as file:
            file.write(
            """<p>""" + contents + """</p>
            <img src='wordcloud.png' style='width:400px;height:300px;'>
            <img src='spelling_pie.png' style='width:400px;height:300px;'>
            <img src='spelling_bar.png' style='width:400px;height:300px;'>
            <img src='similarities_graph.png' style='width:400px;height:300px;'>""")

        generate_prediction(contents)
        webview.create_window("""Essay Assessment Dashboard
         for file{}""".format(GraphicUserInterfaces.current_file),
             "images/index.html")
        webview.start(http_server=True)
def main(k_array, data, data_test):
    data_train = pd.read_csv(data)
    data_test = pd.read_csv(data_test)
    for i in k_array:
        KnnVisualisation2dWithTestSet(data_train, data_test, i).visualisation()

    webview.start()
示例#14
0
def start_webview():
    window = webview.create_window('Howdimain',
                                   url='https://www.howdiweb.nl',
                                   confirm_close=True,
                                   width=1000,
                                   height=600)
    webview.start()
    window.closed = os._exit(0)
示例#15
0
def render_window(title,content):
    """
    Renders the content in a webview window.
    :param title: Title of the window
    :param content: html content to render
    """
    webview.create_window(title=title, html=content)
    webview.start()
示例#16
0
def main():
    # Try to run setup the marker in the current directory, but this
    # might fail if command line args are not specified. Don't do
    # anything here, user will be prompted to pick dir in UI.
    setupMarker()

    window = webview.create_window('Marker', app, width=1280, height=800, easy_drag=True)
    webview.start()
def show_floorplan(input_pipe):
    prepare_prediction()
    window = webview.create_window('Floorplan',
                                   html='Loading...',
                                   width=800,
                                   height=700,
                                   frameless=False)
    webview.start(load_html, (window, input_pipe))
def start_window():
    global p_gui, p_http_server, p_debug, window, window_is_alive
    window_is_alive = True
    wv.start(viewport.bg_tasks.background_thread,
             window,
             gui=p_gui,
             debug=p_debug,
             http_server=p_http_server)
示例#19
0
 def FIND_ARTICLE(self):
     # To pass custom settings to CEF, import and update settings dict
     from webview.platforms.cef import settings
     settings.update({
         'persist_session_cookies': True,
     })
     webview.create_window('CEF Example',
                           'https://en.wikipedia.org/wiki/Special:Random')
     webview.start(gui='cef')
示例#20
0
def start_webpage():
    log.debug("Starting Webpage")
    webview.create_window("",
                          HTML_FILES,
                          js_api=api,
                          width=WINDOW_WIDTH,
                          height=WINDOW_HEIGHT,
                          frameless=True)
    webview.start(gui='gtk')
示例#21
0
 def __init__(self):
     self.dir = './views/static/'
     file_path = self.dir + 'page.html'
     self.width = 800
     self.hegiht = 600
     webview.create_window('References',
                           file_path,
                           width=self.width,
                           height=self.hegiht)
     webview.start()
示例#22
0
def app():
    global isPackaged
    window = webview.create_window('PrivacyFlash Pro',
                                   url='./interface/index.html',
                                   background_color='#f8f9fa',
                                   width=1366,
                                   height=768,
                                   text_select=True)
    window._js_api = Api(window)
    webview.start(http_server=True, debug=False if isPackaged else True)
示例#23
0
def _main_pywebview():
    PORT = 21934

    webview = threading.Thread(target=start_server, args=(PORT, ), daemon=True)
    webview.start()

    #webview.join()

    time.sleep(0.3)

    start_py_web_view(PORT)
示例#24
0
 def start(self):
     api = Api()
     self.window = webview.create_window(
         "Магазин приложений", 
         "../front/dist/index.html",
         js_api=api, 
         width=self.width, 
         height=self.height, 
         resizable=self.resizable,
     )
     webview.start(gui='cef', http_server=False, debug=True)
示例#25
0
def launch():
    """
    Launch a pywebview and bottle powered web-based UI for ArgDB
    """
   
    thread = threading.Thread(target=run, kwargs=dict(host='localhost', port=8080))
    thread.daemon = True
    thread.start()

    webview.create_window("ArgDB", "http://localhost:8080", width=800, height=600, resizable=False)
    webview.start()
示例#26
0
 def serve_forever(self):
     try:
         import webview
     except ImportError:
         raise ImportError('PyWebView is missing. Please install it by:\n    '
                           'pip install pywebview\n    '
                           'more info at https://github.com/r0x0r/pywebview')
     else:
         Server.start(self)
         webview.create_window(self.title, self.address, **self._application_conf)
         webview.start()
         Server.stop(self)
示例#27
0
def main():
    global window
    config = Config()
    api = Api(config)

    window = webview.create_window('PogUI',
                                   INDEX_HTML,
                                   js_api=api,
                                   min_size=(600, 450),
                                   text_select=True)
    window.closed += on_closed
    webview.start(load_page_data, window, debug=config.get('debug', False))
示例#28
0
def main():
    logger.info(f'\n#\n# Booting Kanmail {get_version()}\n#')

    init_window_hacks()
    boot()

    server_thread = Thread(name='Server', target=run_server)
    server_thread.daemon = True
    server_thread.start()

    run_thread(validate_or_remove_license)
    run_thread(run_cache_cleanup_later)

    # Ensure the webserver is up & running by polling it
    waits = 0
    while waits < 10:
        try:
            response = requests.get(
                f'http://{SERVER_HOST}:{server.get_port()}/ping')
            response.raise_for_status()
        except requests.RequestException as e:
            logger.warning(f'Waiting for main window: {e}')
            sleep(0.1 * waits)
            waits += 1
        else:
            break
    else:
        logger.critical('Webserver did not start properly!')
        sys.exit(2)

    create_window(
        unique_key='main',
        **get_window_settings(),
    )

    # Let's hope this thread doesn't fail!
    monitor_thread = Thread(
        name='Thread monitor',
        target=monitor_threads,
        args=(server_thread, ),
    )
    monitor_thread.daemon = True
    monitor_thread.start()

    if DEBUG:
        sleep(1)  # give webpack a second to start listening

    # Start the GUI - this will block until the main window is destroyed
    webview.start(gui=GUI_LIB, debug=DEBUG)

    # Main window closed, cleanup/exit
    sys.exit()
示例#29
0
def main():
    global sync
    print(sys.argv)
    url = "index.html"
    if len(sys.argv) > 1:
        url = sys.argv[1]
    print("main thread id:", threading.get_ident())

    data_dir = appdirs.user_data_dir(APPNAME)
    if not os.path.exists(data_dir):
        os.mkdir(data_dir)

    setting = read_setting_db()
    if not setting:
        setting = {
            "workspace": os.path.join(Path.home(), "gitCloud"),
            "interval": config.SYNC_INTERVAL
        }
    print("setting:", setting)
    excludesFile = os.path.join(appdirs.user_data_dir(APPNAME), ".gitignore")
    createExcludesFile(excludesFile)
    print("excludesFile:", excludesFile)

    workspace = setting["workspace"]
    if not os.path.exists(workspace):
        os.mkdir(workspace)

    if os.path.isabs(config.GIT):
        path = os.path.dirname(config.GIT)
        env_path = os.getenv("PATH")
        if env_path:
            env_path = env_path + ":" + path
        else:
            env_path = path
        set_env_path(env_path)

    api = Api(setting)
    repos = [repo.copy() for repo in api.repos]
    sync = Sync(repos, event_q, setting["interval"], excludesFile)

    window = webview.create_window('gitCloud',
                                   url,
                                   width=400,
                                   height=680,
                                   js_api=api)
    api.window = window

    api.start()
    sync.start(sync_q, workspace)

    webview.start(debug=config.DEBUG)
示例#30
0
def set_up():
    logger.debug('Starting server')
    t = Thread(target=run_server)
    t.daemon = True
    t.start()
    logger.debug('Checking server')

    while not url_ok('127.0.0.1', PORT):
        sleep(1)

    logger.debug('Server started')
    logger.debug('Binding on port ' + str(PORT))
    create_webview()
    webview.start(debug=True, gui='qt')