From: Brian M. <mrb...@gm...> - 2005-11-19 07:15:18
|
On 11/18/05, anrxc <an...@hi...> wrote: > > Hi, I have a little issue maybe someone can help me out. > > I created a MultiColumnList and a TextArea. > In the MultiColumnList I display a list of files in some directory that > contains txt files: > def on_initialize(self, event): > lista =3D os.listdir(pkDir) > lista.sort() > self.components.packs.Append(lista) > > And upon selecting a file in the list I want to display it's contents in > the TextArea: > def on_packs_select(self, event): > base =3D self.components > redovi =3D base.packs.getStringSelection() > red =3D redovi[0] > > os.chdir(pkDir) > f =3D file(red, 'r') > for line in f.readlines(): > base.descs.text =3D line > > > So this works, but I only get displayed the last line in the file. > > If I add "print line" to the end of the function I can see the whole file > being printed to my terminal, so why TextArea displays only the last line= ? > > > In the "for" loop of file f the statement base.desc.text =3D line is SETTING base.desc.text to the latest value of line, I think you want to be APPENDING the value of each line for line in f: # f is enough, no readlines() is necessary base.desc.text +=3D line # appending |