|
4 | 4 | __author__ = 'Simon Robinson'
|
5 | 5 | __copyright__ = 'Copyright (c) 2021 Simon Robinson'
|
6 | 6 | __license__ = 'Apache 2.0'
|
7 |
| -__version__ = '2022-02-07' # ISO 8601 |
| 7 | +__version__ = '2022-03-21' # ISO 8601 |
8 | 8 |
|
9 | 9 | import argparse
|
10 | 10 | import asyncore
|
|
31 | 31 | import urllib.parse
|
32 | 32 | import urllib.error
|
33 | 33 |
|
| 34 | +import pkg_resources |
34 | 35 | import pystray
|
35 | 36 | import timeago
|
36 | 37 | import webview
|
@@ -1084,7 +1085,13 @@ def __init__(self):
|
1084 | 1085 | self.load_and_start_servers(self.icon)
|
1085 | 1086 | else:
|
1086 | 1087 | self.icon = self.create_icon()
|
1087 |
| - self.icon.run(self.post_create) |
| 1088 | + try: |
| 1089 | + self.icon.run(self.post_create) |
| 1090 | + except NotImplementedError: |
| 1091 | + Log.info('Error initialising icon - did you mean to run in --no-gui mode?') |
| 1092 | + self.exit(None) |
| 1093 | + # noinspection PyProtectedMember |
| 1094 | + self.icon._Icon__queue.put(False) # pystray sets up the icon thread even in dummy mode; need to exit |
1088 | 1095 |
|
1089 | 1096 | # noinspection PyUnresolvedReferences
|
1090 | 1097 | def init_platforms(self):
|
@@ -1273,7 +1280,13 @@ def create_authorisation_window(self, request):
|
1273 | 1280 | else:
|
1274 | 1281 | authorisation_window = webview.create_window(window_title, request['permission_url'], on_top=True)
|
1275 | 1282 | setattr(authorisation_window, 'get_title', AuthorisationWindow.get_title) # add missing get_title method
|
1276 |
| - authorisation_window.loaded += self.authorisation_window_loaded |
| 1283 | + |
| 1284 | + # pywebview 3.6+ moved window events to a separate namespace in a non-backwards-compatible way |
| 1285 | + if pkg_resources.parse_version( |
| 1286 | + pkg_resources.get_distribution('pywebview').version) < pkg_resources.parse_version('3.6'): |
| 1287 | + authorisation_window.loaded += self.authorisation_window_loaded |
| 1288 | + else: |
| 1289 | + authorisation_window.events.loaded += self.authorisation_window_loaded |
1277 | 1290 |
|
1278 | 1291 | def handle_authorisation_windows(self):
|
1279 | 1292 | if not sys.platform == 'darwin':
|
@@ -1544,6 +1557,9 @@ def load_and_start_servers(self, icon=None):
|
1544 | 1557 | return True
|
1545 | 1558 |
|
1546 | 1559 | def post_create(self, icon):
|
| 1560 | + if EXITING: |
| 1561 | + return # to handle launch in pystray 'dummy' mode without --no-gui option (partial initialisation failure) |
| 1562 | + |
1547 | 1563 | icon.visible = True
|
1548 | 1564 |
|
1549 | 1565 | if not self.load_and_start_servers(icon):
|
|
0 commit comments