Skip to content

Commit c9558bf

Browse files
Toddpeircej
authored andcommitted
BF: Use relative paths for resource files
1 parent 3e7dd11 commit c9558bf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

psychopy/app/builder/dialogs/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def __init__(self, dlg, label, param, parent, fieldName,
155155
elif param.valType == 'fileList':
156156
self.valueCtrl = FileListCtrl(parent,
157157
choices=param.val,
158-
size=wx.Size(self.valueWidth, 100)
158+
size=wx.Size(self.valueWidth, 100),
159+
pathtype="rel"
159160
)
160161
elif len(param.allowedVals) > 1:
161162
# there are limited options - use a Choice control
@@ -1932,9 +1933,10 @@ def show(self):
19321933
return wx.ID_OK
19331934

19341935
class FileListCtrl(wx.ListBox):
1935-
def __init__(self, parent, choices=[], size=None):
1936+
def __init__(self, parent, choices=[], size=None, pathtype="rel"):
19361937
wx.ListBox.__init__(self)
19371938
parent.Bind(wx.EVT_DROP_FILES, self.addItem)
1939+
self.app = parent.app
19381940
if type(choices) == str:
19391941
choices = data.utils.listFromString(choices)
19401942
self.Create(id=wx.ID_ANY, parent=parent, choices=choices, size=size, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
@@ -1956,8 +1958,12 @@ def addItem(self, event):
19561958
wildcard=_translate(_wld))
19571959
if dlg.ShowModal() != wx.ID_OK:
19581960
return 0
1959-
filename = dlg.GetPaths()
1960-
self.InsertItems(filename, 0)
1961+
filenames = dlg.GetPaths()
1962+
relname = []
1963+
for filename in filenames:
1964+
relname.append(
1965+
os.path.relpath(filename, self.GetTopLevelParent().frame.filename))
1966+
self.InsertItems(relname, 0)
19611967
else:
19621968
fileList = event.GetFiles()
19631969
for filename in fileList:

0 commit comments

Comments
 (0)