|
4 | 4 | __author__ = 'Simon Robinson'
|
5 | 5 | __copyright__ = 'Copyright (c) 2022 Simon Robinson'
|
6 | 6 | __license__ = 'Apache 2.0'
|
7 |
| -__version__ = '2022-07-09' # ISO 8601 (YYYY-MM-DD) |
| 7 | +__version__ = '2022-08-03' # ISO 8601 (YYYY-MM-DD) |
8 | 8 |
|
9 | 9 | import argparse
|
10 | 10 | import asyncore
|
|
38 | 38 | import pkg_resources
|
39 | 39 | import pystray
|
40 | 40 | import timeago
|
| 41 | + |
| 42 | +# noinspection PyPackageRequirements |
41 | 43 | import webview
|
42 | 44 |
|
43 | 45 | # for drawing the menu bar icon
|
@@ -1638,8 +1640,15 @@ def get_image():
|
1638 | 1640 | @staticmethod
|
1639 | 1641 | def get_icon_size(font_file, text, font_size):
|
1640 | 1642 | font = ImageFont.truetype(font_file, size=font_size)
|
1641 |
| - font_width, font_height = font.getsize(text) |
1642 |
| - return font, font_width, font_height |
| 1643 | + |
| 1644 | + # pillow's getsize method was deprecated in 9.2.0 (see docs for PIL.ImageFont.ImageFont.getsize) |
| 1645 | + if pkg_resources.parse_version( |
| 1646 | + pkg_resources.get_distribution('pillow').version) < pkg_resources.parse_version('9.2.0'): |
| 1647 | + font_width, font_height = font.getsize(text) |
| 1648 | + return font, font_width, font_height |
| 1649 | + else: |
| 1650 | + left, top, right, bottom = font.getbbox(text) |
| 1651 | + return font, right, bottom |
1643 | 1652 |
|
1644 | 1653 | def create_config_menu(self):
|
1645 | 1654 | items = [pystray.MenuItem('Servers:', None, enabled=False)]
|
@@ -1760,6 +1769,7 @@ def handle_authorisation_windows(self):
|
1760 | 1769 |
|
1761 | 1770 | # on macOS we need to add extra webview functions to detect when redirection starts, because otherwise the
|
1762 | 1771 | # pywebview window can get into a state in which http://localhost navigation, rather than failing, just hangs
|
| 1772 | + # noinspection PyPackageRequirements |
1763 | 1773 | import webview.platforms.cocoa
|
1764 | 1774 | setattr(webview.platforms.cocoa.BrowserView.BrowserDelegate, 'webView_didStartProvisionalNavigation_',
|
1765 | 1775 | ProvisionalNavigationBrowserDelegate.webView_didStartProvisionalNavigation_)
|
|
0 commit comments