forked from zserge/webview-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpywebview.py
28 lines (20 loc) · 891 Bytes
/
pywebview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import argparse
import os
import webview
def main():
p = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
p.add_argument('url')
p.add_argument('-s', '--size', default='800x600', help='Window size in the form <WIDTH>x<HEIGHT>')
p.add_argument('-f', '--fixed-size', action='store_true', help='Makes the window non-resizable')
p.add_argument('-t', '--title', default='Webview', help='Set the window title')
args = p.parse_args()
try:
width, height = map(int, args.size.split('x'))
except Exception:
p.error('Size must be of the form <WIDTH>x<HEIGHT>')
if not os.path.exists(args.url) and '://' not in args.url:
args.url = 'http://' + args.url
w = webview.WebView(width, height, resizable=not args.fixed_size, url=args.url, title=args.title)
w.run()
if __name__ == "__main__":
main()