Example #1
0
 def serve_forever(self):
     try:
         import webview
         Server.start(self)
         webview.create_window(self.title, self.address, **self._application_conf)
         Server.stop(self)
     except ImportError:
         raise ImportError('PyWebView is missing. Please install it by:\n    '
                           'pip install pywebview\n    '
                           'more info at https://github.com/r0x0r/pywebview')
Example #2
0
def main():

    parser = GooeyParser()

    subparser = parser.add_subparsers()
    dimensions_parser = subparser.add_parser('dimensions')

    dimensions_parser.add_argument('--dimension',
                                   widget='Dropdown',
                                   dest='dimension_value',
                                   choices=config.DIMENSION_NAMES,
                                   help='dimension to run',
                                   required=True)
    dimensions_parser.add_argument('--list_len',
                                   dest='list_len_value',
                                   help='list length',
                                   required=True)
    dimensions_parser.add_argument('--rule_name',
                                   dest='rule_name_value',
                                   help='rule name',
                                   required=True)
    dimensions_parser.add_argument('--param',
                                   dest='rule_param_value',
                                   help='rule param',
                                   required=True)

    preview_parser = subparser.add_parser('play')
    preview_parser.add_argument('--do_preview',
                                widget='Dropdown',
                                dest='do_preview_value',
                                choices=["play as human", "let ML guess"])

    results = parser.parse_args()

    try:
        if results.do_preview_value == "play as human":

            def display_html():
                html_to_display = TH.to_html()
                webview.load_html(html_to_display)

            t = threading.Thread(target=display_html)
            t.start()
            webview.create_window('Play', width=850, height=600)
        else:
            P.predict_bool()

    except:
        R = Run()
        print("Generating list of " + str(results.list_len_value) +
              " hands with " + str(config.CARDS_TO_DRAW) + " cards")
        R.generate_list(results.dimension_value, results.list_len_value,
                        [results.rule_name_value, results.rule_param_value])
        RC = RunCsv()
        RC.generate_csv()
Example #3
0
def simple_browser():
    import webview

    def _simple_browser(webview):
        assert webview.webview_ready(10)
        destroy_event.set()

    t = threading.Thread(target=_simple_browser, args=(webview,))
    t.start()
    destroy_event = destroy_window(webview)
    webview.create_window('Simple browser test', 'https://www.example.org')
Example #4
0
def fullscreen():
    import webview

    def _fullscreen(webview):
        assert webview.webview_ready(10)
        destroy_event.set()

    t = threading.Thread(target=_fullscreen, args=(webview,))
    t.start()
    destroy_event = destroy_window(webview)
    webview.create_window('Fullscreen test', 'https://www.example.org', fullscreen=True)
Example #5
0
def load_html():
    import webview

    def _load_html(webview):
        webview.load_html('<h1>This is dynamically loaded HTML</h1>')

    t = threading.Thread(target=_load_html, args=(webview, ))
    t.start()
    destroy_window(webview)

    webview.create_window('Load html test', 'https://www.example.org')
Example #6
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()
Example #7
0
def toggle_fullscreen():
    import webview

    def _toggle_fullscreen(webview):
        webview.toggle_fullscreen()

    t = threading.Thread(target=_toggle_fullscreen, args=(webview,))
    t.start()
    destroy_window(webview)

    webview.create_window('Toggle fullscreen test', 'https://www.example.org')
Example #8
0
 def serve_forever(self):
     try:
         import webview
         Server.start(self)
         webview.create_window(self.title, self.address,
                               **self._application_conf)
         Server.stop(self)
     except ImportError:
         raise ImportError(
             'PyWebView is missing. Please install it by:\n    pip install pywebview\n    more info at https://github.com/r0x0r/pywebview'
         )
Example #9
0
    def DesktopWebView(self, url="/"):

        if self.app_type == "browser":
            print "browser started"
            import webbrowser as wb

            wb.open(url)

        else:

            print "webview started"
            webview.create_window(__file__, url, resizable=True)
Example #10
0
def load_html():
    import webview

    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()

    t = threading.Thread(target=_load_html, args=(webview,))
    t.start()
    destroy_event = destroy_window(webview)

    webview.create_window('Multi-window load html test', 'https://www.example.org')
Example #11
0
def load_url():
    import webview

    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()

    t = threading.Thread(target=_load_url, args=(webview,))
    t.start()
    destroy_event = destroy_window(webview)

    webview.create_window('Multi-window load url test', 'https://www.example.org')
Example #12
0
def bg_color():
    import webview

    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()

    t = threading.Thread(target=_bg_color, args=(webview,))
    t.start()
    destroy_event = destroy_window(webview, 5)

    webview.create_window('Multi-window background test', 'https://www.example.org')
Example #13
0
    def inicialize(self, parent):
        Lb1 = Label(parent, text="First Name")
        Lb1.grid(row=0, column=0)
        t = threading.Thread(target=load_html)
        t.start()
        webview.create_window('Load HTML Example')

        webview.create_window("Meu navegador",
                              "./Nota_Fiscal.html",
                              width=800,
                              height=600,
                              resizable=True,
                              fullscreen=False)
        webview.load_url("./Nota_Fiscal.html")
Example #14
0
def main():
    """docstring for main"""
    logger.debug('Start server')
    t = Thread(target=run_server)
    t.daemon = True
    t.start()

    logger.debug("Checking server")
    while not url_ok('127.0.0.1', 5000):
        sleep(0.1)

    webview.create_window("It works, Jim!",
                          'http://127.0.0.1:5000',
                          min_size=(1200, 760))
Example #15
0
def run(func):
    def thread():
        time.sleep(1)

        index = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             "index_led.html")
        webview.load_html(open(index).read())
        time.sleep(1)

        func()

    t = Thread(target=thread)
    t.start()

    webview.create_window("Test", "", width=700, height=700)
Example #16
0
def invalid_bg_color():
    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#dsg0000FF')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='FF00FF')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#ac')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#EFEFEH')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#0000000')
def runInBrowser(run=True):
    #run in browser or in pywebview browser
    if run:
        if __name__ == "__main__":
            app.run(host='127.0.0.1', port=5000, debug=True)
    else:
        def start_server():
            app.run()

        if __name__ == '__main__':
            t = threading.Thread(target=start_server)
            t.daemon = True
            t.start()
            webview.create_window("FollowUp-DC", "http://127.0.0.1:5000/", width=1024, height=720)
            sys.exit()
def activate(enable_debug: bool = False) -> None:
    """Activates the GUI context.
If 'enable_debug' is set to 'True', enables the web console."""

    api = __API()
    html_file = pkg_resources.resource_filename("scruml", "assets/scruml.html")

    if enable_debug:
        print("Developer console enabled!")

    webview.create_window(
        "ScrUML", html_file, min_size=(1024, 720), js_api=api, confirm_close=True
    )

    webview.start(debug=enable_debug)
Example #19
0
def invalid_bg_color():
    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#dsg0000FF')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='FF00FF')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#ac')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#EFEFEH')

    with pytest.raises(ValueError):
        webview.create_window('Background color test', 'https://www.example.org', background_color='#0000000')
Example #20
0
def wifi_link(receiver,append_url):
    '''
    打开wifi窗口并返回该对象
    :return: web_app
    '''
    if not is_windows:
        web_app = htmlPy.WebAppGUI(title=u"Python Website",
                                   width=450, height=250,
                                   developer_mode=True)
        # 获取中心点坐标
        cp = QtGui.QDesktopWidget().availableGeometry().center()
        x, y = re.findall(r'\d+', str(cp))
        # 修改窗口坐标
        web_app.x_pos = int(x) - web_app.width / 2
        web_app.y_pos = int(y) - web_app.height / 2

        # 隐藏菜单栏
        # web_app.window.setWindowFlags(QtCore.Qt.FramelessWindowHint)

        web_app.url = u"%s%s#/wifi_connect_win" % (base_url,append_url)

        t = threading.Thread(target=close_message_listener_htmlpy,args=(receiver,web_app))#接收关闭信号并关闭窗口的线程
        t.start()
        web_app.start()
    else:
        t = threading.Thread(target=close_message_listener,args=(receiver,))#接收关闭信号并关闭窗口的线程
        t.start()
        uid = webview.create_window("连接wifi", "%s#/wifi_connect_win" % base_url,width=450, height=250)
        return uid
Example #21
0
    def _run():
        globals()["window"] = web.app.WINDOW = tools.WINDOW = webview.create_window(
            "Журнал термометрии",
            web.app.app,
            width=1080,
            height=720,
            easy_drag=False,
            js_api=js_api,
            min_size=(940, 570),
        )

        # Добавляем дополнительные методы к JSApi
        window.expose(
            change_color_scheme,
            add_group,
            delete_group,
            edit_group,
            get_group_members,
            get_now_time,
        )

        # Добавляем обработчики событий
        window.loaded += _on_loaded
        window.closed += _on_closed
        window.shown += _on_shown

        start_window.destroy()  # Закрываем стартовое окно
Example #22
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)
Example #23
0
def test_move_window():
    window = webview.create_window('Move window test',
                                   x=200,
                                   y=200,
                                   width=100,
                                   height=100)
    run_test(webview, window, move_window)
Example #24
0
def test_xy():
    window = webview.create_window('xy test',
                                   x=200,
                                   y=200,
                                   width=100,
                                   height=100)
    run_test(webview, window, xy)
def no_resize():
    import webview

    def _no_resize(webview):
        assert webview.webview_ready(10)
        destroy_event.set()

    t = threading.Thread(target=_no_resize, args=(webview, ))
    t.start()
    destroy_event = destroy_window(webview)
    webview.create_window('Min size test',
                          'https://www.example.org',
                          width=800,
                          height=600,
                          resizable=True,
                          min_size=(400, 200))
Example #26
0
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)
Example #27
0
def create_webview():
    return webview.create_window(
        'T3-ALPHA(NON PRODUCTION) - Turtle Network Wallet',
        'http://127.0.0.1:' + str(PORT),
        text_select=True,
        confirm_close=True,
        min_size=(1500, 600))
Example #28
0
 def setupWindow(self):
     self._window = webview.create_window("",
                                          HTML_FILES,
                                          js_api=api,
                                          width=WINDOW_WIDTH,
                                          height=WINDOW_HEIGHT,
                                          fullscreen=True)
Example #29
0
def create_new_window():
    # Create new window and store its uid
    child_window = webview.create_window('Window #2', width=800, height=400)

    # Load content into both windows
    webview.load_html('<h1>Master Window</h1>')
    webview.load_html('<h1>Child Window</h1>', uid=child_window)
Example #30
0
File: gui.py Project: 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)
Example #31
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()
Example #32
0
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)
Example #33
0
def localization():
    strings = {
        "cocoa.menu.about": u"О программе",
        "cocoa.menu.services": u"Cлужбы",
        "cocoa.menu.view": u"Вид",
        "cocoa.menu.hide": u"Скрыть",
        "cocoa.menu.hideOthers": u"Скрыть остальные",
        "cocoa.menu.showAll": u"Показать все",
        "cocoa.menu.quit": u"Завершить",
        "cocoa.menu.fullscreen": u"Перейти ",
        "windows.fileFilter.allFiles": u"Все файлы",
        "windows.fileFilter.otherFiles": u"Остальлные файльы",
        "linux.openFile": u"Открыть файл",
        "linux.openFiles": u"Открыть файлы",
        "linux.openFolder": u"Открыть папку",
        "linux.saveFile": u"Сохранить файл",
    }

    webview.create_window('Localization test', 'https://www.example.org', strings=strings)
Example #34
0
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)
Example #35
0
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)
Example #36
0
import webview
import threading

"""
This example demonstrates how to create a pywebview windows using QT (normally GTK is preferred)
"""

if __name__ == '__main__':
    webview.config.use_qt = True

    # Create a non-resizable webview window with 800x600 dimensions
    webview.create_window("Simple browser", "http://flowrl.com")
Example #37
0
import webview

"""
This example demonstrates how to create a CEF window. Available only on Windows.
"""

if __name__ == '__main__':
    # Create a CEF window
    webview.config.gui = 'cef'
    webview.create_window('CEF browser', 'https://pywebview.flowrl.com/hello')
Example #38
0
import webview
import threading

"""
This example demonstrates how a webview window is created and destroyed programmatically after 5 seconds
"""
#import os
#os.environ["USE_GTK"] = "true"

def destroy():
    import time
    time.sleep(5)
    print("Destroying window..")
    webview.destroy_window()


if __name__ == '__main__':
    t = threading.Thread(target=destroy)
    t.start()
    webview.create_window("Simple browser", "http://www.google.com")
    print("Window is destroyed")

Example #39
0
              if evt.type in [X.KeyPress, X.KeyRelease]: #ignore X.MappingNotify(=34)
                 handle_event(evt)
              #else handle_event_pinyin(evt)

          data=''
          try:
              data, address=sock.recvfrom(4096)
              if data!='':
                  print 'receive udp:',data
                  #{"detail":"j", "state":0, "type":2}
                  #{"detail":"j", "state":0, "type":3}
                  evt_key=json.loads(data);
                  if is_on:
                      if evt_key['detail']=='f':
                          evt_key['detail']='s'
                      elif evt_key['detail']=='s':
                          evt_key['detail']='f'
                  evt_key={'detail':string_to_keycode(evt_key['detail']), 'state':evt_key['state'], 'type':evt_key['type']}
                  if evt_key['type']==5:
                      fake_input(disp, 2, evt_key['detail'])
                      fake_input(disp, 3, evt_key['detail'])
                  else:
                      fake_input(disp, evt_key['type'], evt_key['detail'])
                  #handle_event(namedtuple('Struct', evt_key.keys())(*evt_key.values()))
          except socket.error:
              continue

if __name__ == '__main__':
    thread.start_new_thread(main, ())
    webview.create_window('myboard_jack', 'https://www.google.com', None, screen.width_in_pixels-200, 0, False, False)
Example #40
0
import time
from logging import DEBUG, FileHandler
from schedule.view import app

app.logger.setLevel(DEBUG)
app.logger.addHandler(FileHandler('flask.log'))

try:
  import webview
  import multiprocessing

  p = multiprocessing.Process(target=lambda: app.run(),args=())
  p.start()

  print "Opening view"
  time.sleep(1)
  webview.create_window("CSD Schedule","http://localhost:5000")

  p.join()

except ImportError:
  import webbrowser

  print "Opening browser"
  webbrowser.open("http://localhost:5000")

  app.run()
Example #41
0
import os
os.environ["USE_GTK"] = "true"

import webview

"""
This example creates a webview window using GTK (normally QT is preferred)
"""

if __name__ == '__main__':
    webview.create_window("GTK browser", "http://www.flowrl.com")

Example #42
0
import webview
import threading

"""
This example demonstrates creating a save file dialog.
"""


def save_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.SAVE_DIALOG,
                                     directory="/",
                                     save_filename='test.file'))


if __name__ == '__main__':
    t = threading.Thread(target=save_file_dialog)
    t.start()

    webview.create_window("Save file dialog", "https://pywebview.flowrl.com/hello")
Example #43
0
 def serve_forever(self):
     import webview
     Server.start(self)
     webview.create_window(self._application_name, self.address, **self._application_conf)
     Server.stop(self)
Example #44
0
import webview

"""
This example demonstrates how to create a webview window.
"""

if __name__ == '__main__':
    # Create a non-resizable webview window with 800x600 dimensions
    webview.create_window("Simple browser", "http://www.flowrl.com", width=800, height=600, resizable=False)

Example #45
0
import webview
import threading
import time

"""
This example demonstrates how to toggle fullscreen mode programmatically.
"""


def toggle_fullscreen():
    # wait a few seconds before toggle fullscreen:
    time.sleep(5)

    webview.toggle_fullscreen()


if __name__ == '__main__':
    t = threading.Thread(target=toggle_fullscreen)
    t.start()

    webview.create_window("Full-screen window", "https://pywebview.flowrl.com/hello")
Example #46
0
import webview

"""
This example demonstrates a webview window with a quit confirmation dialog.
"""

if __name__ == '__main__':
    # Create a standard webview window
    webview.create_window("Confirm Quit Example",
                          "https://pywebview.flowrl.com/hello",
                          confirm_quit=True)
Example #47
0
except ImportError:
    from http.server import SimpleHTTPRequestHandler, HTTPServer


"""
This example demonstrates how a trivial application can be built using a HTTP server combined with a web view.
"""

def start_server():
    HandlerClass = SimpleHTTPRequestHandler
    ServerClass = HTTPServer
    Protocol = "HTTP/1.0"
    port = 23948
    server_address = ('127.0.0.1', port)

    HandlerClass.protocol_version = Protocol
    httpd = ServerClass(server_address, HandlerClass)
    httpd.serve_forever()


if __name__ == '__main__':
    t = threading.Thread(target=start_server)
    t.daemon = True
    t.start()

    webview.create_window("My first HTML5 application", "http://127.0.0.1:23948")

    # do clean up procedure and destroy any remaining threads after the window is destroyed
    sys.exit()

Example #48
0
def min_size():
    webview.create_window('Min size test', 'https://www.example.org',
                          width=800, height=600, resizable=True, min_size=(400, 200))
Example #49
0
import webview

"""
This example demonstrates how to enable debugging of webview content. To open
up debugging console, right click on an element and select Inspect.
"""

if __name__ == '__main__':
    webview.create_window('Debug window', 'https://pywebview.flowrl.com/hello', debug=True)
 def start(self):
     thread.start_new_thread(self.counter, (2, "https://calendar.google.com?mode=day", 0))
     webview.create_window("wall program", "html/start.html", fullscreen=True)
Example #51
0
def main_func():
    webview.create_window('Simple browser test', 'https://www.example.org')
Example #52
0
import webview
import threading

"""
This example demonstrates how to load HTML in a web view window
"""

def load_html():
    webview.load_html("<h1>This is dynamically loaded HTML</h1>")


if __name__ == '__main__':
    t = threading.Thread(target=load_html)
    t.start()

    # Create a non-resizable webview window with 800x600 dimensions
    webview.create_window("Simple browser", width=800, height=600, resizable=True)

Example #53
0
import webview
import threading

"""
This example demonstrates how to get the current url loaded in the webview.
"""


def get_current_url():
    print(webview.get_current_url())


if __name__ == '__main__':
    t = threading.Thread(target=get_current_url)
    t.start()

    webview.create_window("Get current URL", "https://pywebview.flowrl.com/hello")
Example #54
0
def url_ok(url, port):
    # Use httplib on Python 2
    try:
        from http.client import HTTPConnection
    except ImportError:
        from httplib import HTTPConnection

    try:
        conn = HTTPConnection(url, port)
        conn.request("GET", "/")
        r = conn.getresponse()
        return r.status == 200
    except:
        logger.exception("Server not started")
        return False

if __name__ == '__main__':
    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", 23948):
        sleep(0.1)

    logger.debug("Server started")
    webview.create_window("My first pywebview application",
                          "http://127.0.0.1:23948",
                          min_size=(640, 480))
Example #55
0
import webview
import threading

"""
This example demonstrates how to load HTML in a web view window
"""


def load_html():
    webview.load_html('<h1>This is dynamically loaded HTML</h1>')


if __name__ == '__main__':
    t = threading.Thread(target=load_html)
    t.start()

    webview.create_window('Load HTML Example')
Example #56
0
import webview
import threading

"""
This example demonstrates how to create and manage multiple windows
"""


def create_new_window():
    # Create new window and store its uid
    child_window = webview.create_window('Window #2', width=800, height=400)

    # Load content into both windows
    webview.load_html('<h1>Master Window</h1>')
    webview.load_html('<h1>Child Window</h1>', uid=child_window)


if __name__ == '__main__':
    t = threading.Thread(target=create_new_window)
    t.start()

    # Master window
    webview.create_window('Window #1', width=800, height=600)
Example #57
0
import webview
import threading

"""
This example demonstrates creating a save file dialog.
"""

def save_file_dialog():
    import time
    time.sleep(5)
    print(webview.create_file_dialog(webview.SAVE_DIALOG, directory="/", save_filename='test.file'))


if __name__ == '__main__':
    t = threading.Thread(target=save_file_dialog)
    t.start()

    webview.create_window("Save file dialog", "http://www.flowrl.com")

Example #58
0
import webview
import threading
import time

"""
This example demonstrates how a webview window is created and destroyed
programmatically after 5 seconds.
"""


def destroy():
    # show the window for a few seconds before destroying it:
    time.sleep(5)

    print("Destroying window..")
    webview.destroy_window()
    print("Destroyed!")


if __name__ == '__main__':
    t = threading.Thread(target=destroy)
    t.start()
    webview.create_window("Destroy Window Example", "https://pywebview.flowrl.com/hello")
    print("Window is destroyed")
Example #59
0
import webview

"""
This example demonstrates a webview window with a quit confirmation dialog
"""

if __name__ == '__main__':
    # Create a standard webview window
    webview.create_window("Simple browser", "http://www.flowrl.com", confirm_quit=True)