#!/usr/bin/env python3

import webview

LOCATION = "http://localhost:9274/welcome"

class Api():
    def log(self, value):
        print(value)
        
    def close(self):
        window.destroy()


def on_closed():
    """
    Actions to take when System Installer is closed.
    """
    print('pywebview window is closed')


window = webview.create_window('System Installer', LOCATION,
                      transparent=True, easy_drag=False, frameless=True,
                      width=1050, height=650, focus=True, zoomable=True,
                      confirm_close=False, resizable=True, shadow=True,
                      text_select=False, draggable=True, js_api=Api()
                      )

webview.settings = {
  'ALLOW_DOWNLOADS': False,
  'ALLOW_FILE_URLS': False,
  'DRAG_REGION_SELECTOR': '.pywebview-drag-region',
  'DRAG_REGION_DIRECT_TARGET_ONLY': True,
  'OPEN_EXTERNAL_LINKS_IN_BROWSER': True,
  'OPEN_DEVTOOLS_IN_DEBUG': True,
  'IGNORE_SSL_ERRORS': False,
  'REMOTE_DEBUGGING_PORT': None,
  'SHOW_DEFAULT_MENUS': True
}


def custom_logic(window):
    pass
    #window.toggle_fullscreen()
    #window.evaluate_js('alert("Nice one brother")')
    #window.destroy()

window.events.closed += on_closed
#webview.start(icon='/usr/share/icons/yasi.png')
webview.start(custom_logic, window)
