Skip to content

Commit

Permalink
BF: Use relative paths for resource files
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd authored and peircej committed Oct 21, 2020
1 parent 3e7dd11 commit c9558bf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions psychopy/app/builder/dialogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def __init__(self, dlg, label, param, parent, fieldName,
elif param.valType == 'fileList':
self.valueCtrl = FileListCtrl(parent,
choices=param.val,
size=wx.Size(self.valueWidth, 100)
size=wx.Size(self.valueWidth, 100),
pathtype="rel"
)
elif len(param.allowedVals) > 1:
# there are limited options - use a Choice control
Expand Down Expand Up @@ -1932,9 +1933,10 @@ def show(self):
return wx.ID_OK

class FileListCtrl(wx.ListBox):
def __init__(self, parent, choices=[], size=None):
def __init__(self, parent, choices=[], size=None, pathtype="rel"):
wx.ListBox.__init__(self)
parent.Bind(wx.EVT_DROP_FILES, self.addItem)
self.app = parent.app
if type(choices) == str:
choices = data.utils.listFromString(choices)
self.Create(id=wx.ID_ANY, parent=parent, choices=choices, size=size, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
Expand All @@ -1956,8 +1958,12 @@ def addItem(self, event):
wildcard=_translate(_wld))
if dlg.ShowModal() != wx.ID_OK:
return 0
filename = dlg.GetPaths()
self.InsertItems(filename, 0)
filenames = dlg.GetPaths()
relname = []
for filename in filenames:
relname.append(
os.path.relpath(filename, self.GetTopLevelParent().frame.filename))
self.InsertItems(relname, 0)
else:
fileList = event.GetFiles()
for filename in fileList:
Expand Down

0 comments on commit c9558bf

Please sign in to comment.