""" Demonstrate usage of the state object to share state between Python and JavaScript. """ import webview html = """
Counter value: 0
""" def on_counter_change(type, key, value): print(f'Event {type} for {key} value : {value}') def decrease_counter(): window.state.counter -= 1 def on_loaded(window): window.expose(decrease_counter) window.state += on_counter_change if __name__ == '__main__': global window window = webview.create_window('State example', html=html) window.state.counter = 0 window.events.loaded += on_loaded webview.start(debug=True)