added _MEIPASS to read xpm/rgb for pyinstaller
This commit is contained in:
1 parent
f45f25dd9d
commit
16ca19db37
1 file changed
+15
-3
@@ -26,7 +26,7 @@ Some changes to handle the additional event handling in pywmgeneral
|
|||||||
First workingish version
|
First workingish version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, re
|
import os, re, sys
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
charset_start = None
|
charset_start = None
|
||||||
@@ -145,7 +145,13 @@ def readXPM(fileName):
|
|||||||
Raise IOError if we run into trouble when trying to read the file. This
|
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
|
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()]
|
lines = [l.rstrip('\n') for l in f.readlines()]
|
||||||
s = ''.join(lines)
|
s = ''.join(lines)
|
||||||
res = []
|
res = []
|
||||||
@@ -436,7 +442,13 @@ def getColorCode(colorName, rgbFileName=None):
|
|||||||
if rgbFileName is None:
|
if rgbFileName is None:
|
||||||
raise ValueError('cannot find rgb file')
|
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()
|
lines = f.readlines()
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l[0] != '!':
|
if l[0] != '!':
|
||||||
|
|||||||
Reference in new issue
Block a user