Commit fbdc8a9e authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rf/wxplatform' into 'master'

Differentiate between GTK2 and GTK3

See merge request fsl/fsleyes/widgets!72
parents 58678ef5 1adde739
......@@ -2,6 +2,18 @@ This document contains the ``fsleyes-widgets`` release history in reverse
chronological order.
0.12.0 (Tuesday April 20th 2021)
--------------------------------
Changed
^^^^^^^
* The :class:`.wxPlatform` function now differentiates between GTK2 and GTK3
``wxPython`` builds.
0.11.3 (Friday April 16th 2021)
-------------------------------
......
......@@ -18,7 +18,7 @@ This file is used to store the current ``fsleyes-widgets`` version.
"""
__version__ = '0.12.0.dev0'
__version__ = '0.13.0.dev0'
from fsleyes_widgets.utils import (WX_PYTHON, # noqa
......@@ -27,6 +27,8 @@ from fsleyes_widgets.utils import (WX_PYTHON, # noqa
WX_MAC_COCOA,
WX_MAC_CARBON,
WX_GTK,
WX_GTK2,
WX_GTK3,
wxversion,
wxVersion,
wxFlavour,
......
......@@ -63,8 +63,20 @@ OSX carbon wx version is being used.
WX_GTK = 3
"""Alias for :attr:`WX_GTK2` - will be removed in a future version of
``fsleyes-widgets``.
"""
WX_GTK2 = 3
"""Constant returned by the :func:`wxPlatform` function, indicating that a
Linux/GTK3 wx version is being used.
"""
WX_GTK3 = 4
"""Constant returned by the :func:`wxPlatform` function, indicating that a
Linux/GTK wx version is being used.
Linux/GTK3 wx version is being used.
"""
......@@ -118,8 +130,8 @@ def wxversion():
def wxPlatform():
"""Returns one of :data:`WX_UNKNOWN` :data:`WX_MAC_COCOA`,
:data:`WX_MAC_CARBON`, or :data:`WX_GTK`, indicating the wx platform, or
``None`` if wxPython does not appear to be installed.
:data:`WX_MAC_CARBON`, :data:`WX_GTK2`, or :data:`WX_GTK3`, indicating the
wx platform, or ``None`` if wxPython does not appear to be installed.
"""
try:
......@@ -131,7 +143,9 @@ def wxPlatform():
if any(['cocoa' in p for p in pi]): plat = WX_MAC_COCOA
elif any(['carbon' in p for p in pi]): plat = WX_MAC_CARBON
elif any(['gtk' in p for p in pi]): plat = WX_GTK
elif any(['gtk3' in p for p in pi]): plat = WX_GTK3
elif any(['gtk2' in p for p in pi]): plat = WX_GTK2
elif any(['gtk' in p for p in pi]): plat = WX_GTK2
else: plat = WX_UNKNOWN
return plat
......
......@@ -84,8 +84,16 @@ def test_wxPlatform():
assert fw.wxPlatform() == fw.WX_MAC_COCOA
with mock.patch('wx.PlatformInfo', ['carbon']):
assert fw.wxPlatform() == fw.WX_MAC_CARBON
with mock.patch('wx.PlatformInfo', ['gtk3']):
assert fw.wxPlatform() == fw.WX_GTK3
with mock.patch('wx.PlatformInfo', ['gtk2']):
assert fw.wxPlatform() == fw.WX_GTK2
# PlatformInfo should have "gtk2" or "gtk3";
# if for some reason it only has "gtk",
# wxPlatform will assume gtk2
with mock.patch('wx.PlatformInfo', ['gtk']):
assert fw.wxPlatform() == fw.WX_GTK
assert fw.wxPlatform() == fw.WX_GTK2
with mock.patch('wx.PlatformInfo', ['atari']):
assert fw.wxPlatform() == fw.WX_UNKNOWN
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment