Skip to content
Snippets Groups Projects
Commit 7ecd9f6d authored by Paul McCarthy's avatar Paul McCarthy
Browse files

settings module uses platform module to test for WX. Also bugfix -

settings.read returns any specified default value even if there is no
GUI.
parent ae3bd438
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
import logging import logging
from .platform import platform as fslplatform
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -55,11 +57,10 @@ def read(name, default=None): ...@@ -55,11 +57,10 @@ def read(name, default=None):
there is no setting called ``name``. there is no setting called ``name``.
""" """
try: import wx if not fslplatform.haveGui:
except: return None return default
if wx.GetApp() is None: import wx
return None
config = wx.Config(_CONFIG_ID) config = wx.Config(_CONFIG_ID)
...@@ -75,12 +76,11 @@ def read(name, default=None): ...@@ -75,12 +76,11 @@ def read(name, default=None):
def write(name, value): def write(name, value):
"""Writes a setting with the given ``name`` and ``value``.""" """Writes a setting with the given ``name`` and ``value``."""
try: import wx if not fslplatform.haveGui:
except: return
if wx.GetApp() is None:
return return
import wx
value = str(value) value = str(value)
config = wx.Config(_CONFIG_ID) config = wx.Config(_CONFIG_ID)
...@@ -91,11 +91,11 @@ def write(name, value): ...@@ -91,11 +91,11 @@ def write(name, value):
def delete(name): def delete(name):
"""Delete the setting with the given ``name``. """ """Delete the setting with the given ``name``. """
try: import wx
except: return
if wx.GetApp() is None: if not fslplatform.haveGui:
return return
import wx
config = wx.Config(_CONFIG_ID) config = wx.Config(_CONFIG_ID)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment