Skip to content

Instantly share code, notes, and snippets.

@WingTillDie
Last active July 22, 2023 20:05
Show Gist options
  • Save WingTillDie/d5a52f7f3969f0388e3a88cb9af66ff7 to your computer and use it in GitHub Desktop.
Save WingTillDie/d5a52f7f3969f0388e3a88cb9af66ff7 to your computer and use it in GitHub Desktop.
Pywebview with set title from document.title
#!/usr/bin/env python3
import argparse
import webview
def set_title():
window = webview.windows[0]
result = window.evaluate_js('document.title')
window.set_title(result)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
prog='webview-document-title.py',
description='Pywebview with set title from document.title',
)
parser.add_argument('URL', nargs='?', default = "https://www.google.com")
args = parser.parse_args()
window = webview.create_window(None, args.URL)
window.events.loaded += set_title
window.events.moved += set_title
webview.start(set_title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment