From b0b24ae9ddcdc0966d0640a973c694d3707a3a90 Mon Sep 17 00:00:00 2001 From: Amir Taaki Date: Sat, 7 Jul 2012 23:25:41 +0100 Subject: [PATCH] Use environment variable else fallback to system app path. This enables runtime switching between styles without modifying Electrum, and avoids potential conflicts from implicit detection of a data/ subdirectory. --- lib/gui_lite.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/gui_lite.py b/lib/gui_lite.py index 58895a957..1c69291ba 100644 --- a/lib/gui_lite.py +++ b/lib/gui_lite.py @@ -36,15 +36,19 @@ def resize_line_edit_width(line_edit, text_input): text_input += "A" line_edit.setMinimumWidth(metrics.width(text_input)) +def cd_data_dir(): + try: + data_dir = os.environ["ELECTRUM_DATA_PATH"] + except KeyError: + data_dir = appdata_dir() + QDir.setCurrent(data_dir) + class ElectrumGui: def __init__(self, wallet): self.wallet = wallet self.app = QApplication(sys.argv) - if os.path.exists("data"): - QDir.setCurrent("data") - else: - QDir.setCurrent(appdata_dir()) + cd_data_dir() with open(rsrc("style.css")) as style_file: self.app.setStyleSheet(style_file.read())