| 919 | |
| 920 | |
| 921 | class StandaloneServer(Server): |
| 922 | def __init__(self, gui_class, title='', width=800, height=600, resizable=True, fullscreen=False, start=True, |
| 923 | userdata=()): |
| 924 | Server.__init__(self, gui_class, title=title, start=False, address='127.0.0.1', port=0, username=None, |
| 925 | password=None, |
| 926 | multiple_instance=False, enable_file_cache=True, update_interval=0.1, start_browser=False, |
| 927 | websocket_timeout_timer_ms=1000, pending_messages_queue_length=1000, userdata=userdata) |
| 928 | |
| 929 | self._application_conf = {'width': width, 'height': height, 'resizable': resizable, 'fullscreen': fullscreen} |
| 930 | |
| 931 | if start: |
| 932 | self.serve_forever() |
| 933 | |
| 934 | def serve_forever(self): |
| 935 | try: |
| 936 | import webview |
| 937 | except ImportError: |
| 938 | raise ImportError('PyWebView is missing. Please install it by:\n ' |
| 939 | 'pip install pywebview\n ' |
| 940 | 'more info at https://github.com/r0x0r/pywebview') |
| 941 | else: |
| 942 | Server.start(self) |
| 943 | webview.create_window(self.title, self.address, **self._application_conf) |
| 944 | webview.start() |
| 945 | Server.stop(self) |
| 946 | |
| 947 | |
| 948 | def start(main_gui_class, **kwargs): |