Skip to content

Commit 4722df0

Browse files
committed
Switch to getbbox for pillow versions 9.2.0 and above
Also force pystray 0.19.4 or later to make addressing #11 easier
1 parent b6ab557 commit 4722df0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

emailproxy.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__author__ = 'Simon Robinson'
55
__copyright__ = 'Copyright (c) 2022 Simon Robinson'
66
__license__ = 'Apache 2.0'
7-
__version__ = '2022-07-09' # ISO 8601 (YYYY-MM-DD)
7+
__version__ = '2022-08-03' # ISO 8601 (YYYY-MM-DD)
88

99
import argparse
1010
import asyncore
@@ -38,6 +38,8 @@
3838
import pkg_resources
3939
import pystray
4040
import timeago
41+
42+
# noinspection PyPackageRequirements
4143
import webview
4244

4345
# for drawing the menu bar icon
@@ -1638,8 +1640,15 @@ def get_image():
16381640
@staticmethod
16391641
def get_icon_size(font_file, text, font_size):
16401642
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
16431652

16441653
def create_config_menu(self):
16451654
items = [pystray.MenuItem('Servers:', None, enabled=False)]
@@ -1760,6 +1769,7 @@ def handle_authorisation_windows(self):
17601769

17611770
# on macOS we need to add extra webview functions to detect when redirection starts, because otherwise the
17621771
# pywebview window can get into a state in which http://localhost navigation, rather than failing, just hangs
1772+
# noinspection PyPackageRequirements
17631773
import webview.platforms.cocoa
17641774
setattr(webview.platforms.cocoa.BrowserView.BrowserDelegate, 'webView_didStartProvisionalNavigation_',
17651775
ProvisionalNavigationBrowserDelegate.webView_didStartProvisionalNavigation_)

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
configobj
22
cryptography
33
pillow
4-
pystray
4+
pystray>=0.19.4 # force pystray version with dummy GUI fix (https://github.com/moses-palmer/pystray/issues/118)
55
pywebview; sys_platform != 'win32' # specify platform to avoid double requirement error with older pip versions
66
timeago
77

0 commit comments

Comments
 (0)