Hi,
I guess, the SetValue method of a TextCtrl only accept strings, you
can join the list like: "\n".join(myFiles).
Note, that os.listdir only returns the data for the respective path,
i.e. not some deeper nested directories, but you probably can control
or assume the directory structure, you are accessing..
hth,
vbr
···
2013/8/25 werner <wbruhin@free.fr>:
On 24/08/2013 23:04, George McCown wrote:
I have a multiline TextCtrl I want to output a bunch of files with re.sub.
This box is just for reading os.listdir for testing:
SetValue is reading only the last file. I understand that. So how can I
use something like . join to re.sub all the files just for reading?
That makes sense, no? You are in a loop and "f" will always only contain
the name of one file.
path = self.dirname
dirList=os.listdir(path)
myFiles =
for self.filename in dirList:
f = self.filename
print f ## reads all files, one at the time!
newF = re.sub(self.PracRemove.GetValue(), self.PracReplace.GetValue(),
f)
myFiles.append(newF)
self.PracInput.SetValue(myFiles) # note that this is not in the loop
I implemented:
myFiles.append(newF)
self.PracInput.SetValue(str(“\n”.join(myFiles)))
Works fine now.
Thanks werner,vbr
One more question, is there a way to mark this post as resolved?
···
On Sunday, August 25, 2013 1:10:20 AM UTC-5, werner wrote: