diff --git a/emailproxy.py b/emailproxy.py index bc0ea77..91b1076 100644 --- a/emailproxy.py +++ b/emailproxy.py @@ -4,7 +4,7 @@ __author__ = 'Simon Robinson' __copyright__ = 'Copyright (c) 2022 Simon Robinson' __license__ = 'Apache 2.0' -__version__ = '2022-07-09' # ISO 8601 (YYYY-MM-DD) +__version__ = '2022-08-03' # ISO 8601 (YYYY-MM-DD) import argparse import asyncore @@ -38,6 +38,8 @@ import pkg_resources import pystray import timeago + +# noinspection PyPackageRequirements import webview # for drawing the menu bar icon @@ -1638,8 +1640,15 @@ def get_image(): @staticmethod def get_icon_size(font_file, text, font_size): font = ImageFont.truetype(font_file, size=font_size) - font_width, font_height = font.getsize(text) - return font, font_width, font_height + + # pillow's getsize method was deprecated in 9.2.0 (see docs for PIL.ImageFont.ImageFont.getsize) + if pkg_resources.parse_version( + pkg_resources.get_distribution('pillow').version) < pkg_resources.parse_version('9.2.0'): + font_width, font_height = font.getsize(text) + return font, font_width, font_height + else: + left, top, right, bottom = font.getbbox(text) + return font, right, bottom def create_config_menu(self): items = [pystray.MenuItem('Servers:', None, enabled=False)] @@ -1760,6 +1769,7 @@ def handle_authorisation_windows(self): # on macOS we need to add extra webview functions to detect when redirection starts, because otherwise the # pywebview window can get into a state in which http://localhost navigation, rather than failing, just hangs + # noinspection PyPackageRequirements import webview.platforms.cocoa setattr(webview.platforms.cocoa.BrowserView.BrowserDelegate, 'webView_didStartProvisionalNavigation_', ProvisionalNavigationBrowserDelegate.webView_didStartProvisionalNavigation_) diff --git a/requirements.txt b/requirements.txt index b645aef..f17f456 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ configobj cryptography pillow -pystray +pystray>=0.19.4 # force pystray version with dummy GUI fix (https://github.com/moses-palmer/pystray/issues/118) pywebview; sys_platform != 'win32' # specify platform to avoid double requirement error with older pip versions timeago