diff --git a/wmdocklib/pywmhelpers.py b/wmdocklib/pywmhelpers.py index ac79eac..89ae9dc 100644 --- a/wmdocklib/pywmhelpers.py +++ b/wmdocklib/pywmhelpers.py @@ -26,7 +26,7 @@ Some changes to handle the additional event handling in pywmgeneral First workingish version """ -import os, re +import os, re, sys import configparser charset_start = None @@ -145,7 +145,13 @@ def readXPM(fileName): Raise IOError if we run into trouble when trying to read the file. This function has not been tested extensively. do not try to use more than """ - with open(fileName, 'r') as f: + if hasattr(sys, '_MEIPASS'): + base_path = os.path.join(sys._MEIPASS, "wmdocklib") + else: + base_path = "wmdocklib" + filePath = os.path.join(base_path, fileName) + + with open(filePath, 'r') as f: lines = [l.rstrip('\n') for l in f.readlines()] s = ''.join(lines) res = [] @@ -436,7 +442,13 @@ def getColorCode(colorName, rgbFileName=None): if rgbFileName is None: raise ValueError('cannot find rgb file') - with open(rgbFileName, 'r') as f: + if hasattr(sys, '_MEIPASS'): + base_path = os.path.join(sys._MEIPASS, "wmdocklib") + else: + base_path = "wmdocklib" + rgbFilePath = os.path.join(base_path, rgbFileName) + + with open(rgbFilePath, 'r') as f: lines = f.readlines() for l in lines: if l[0] != '!':