Skip to content

Instantly share code, notes, and snippets.

@nazmulpcc
Created August 6, 2023 08:08
Show Gist options
  • Save nazmulpcc/b52529610956940aace1a35263184281 to your computer and use it in GitHub Desktop.
Save nazmulpcc/b52529610956940aace1a35263184281 to your computer and use it in GitHub Desktop.
Calling webview from python
from ctypes import CDLL, c_int, c_char_p, c_void_p
# Load the shared library
# https://github.com/webview/webview/
libwebview = CDLL('/path/to/libwebview.so')
# Define the functions with their argument types and return types
libwebview.webview_create.argtypes = [c_int, c_void_p]
libwebview.webview_create.restype = c_void_p
libwebview.webview_navigate.argtypes = [c_void_p, c_char_p]
libwebview.webview_navigate.restype = None
libwebview.webview_run.argtypes = [c_void_p]
libwebview.webview_run.restype = None
# Usage example:
debug = 1
window = None # You can replace this with a proper window pointer if needed
handle = libwebview.webview_create(debug, window)
url = b"http://reactphp.org"
libwebview.webview_navigate(handle, url)
libwebview.webview_run(handle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment