[Tutor] Saving Entry fields in Tkinter

Adam Cripps kabads at gmail.com
Tue Mar 1 16:45:50 CET 2005


On Tue, 1 Mar 2005 15:31:10 +0000, Adam Cripps <kabads at gmail.com> wrote:
> On Tue, 1 Mar 2005 15:30:02 +0000, Adam Cripps <kabads at gmail.com> wrote:
> > On Tue, 1 Mar 2005 12:52:57 +0100, Ewald Ertl <ewald.ertl at hartter.com> wrote:
> > > Hi!
> > >
> > > Perhaps this could help you:
> > >
> > > fileContent=open( "my/file/to/read", "r").readlines()
> > >
> > > for line in fileContent:
> > >         print line.strip()   # remove leading and trailing whitspace's incl. \n
> > >
> > > In the loop you could perhaps populate the entry-widgets.
> > >
> > > HTH
> > >
> > > Ewald
> > >
> > > on Tue, 1 Mar 2005 09:22:06 +0000  Adam Cripps <kabads at gmail.com> wrote :
> > <snip>
> >
> Thanks Ewald - this is what I have so far, with a far from perfect result:
> File=open( FileName, "r")
> readlines = File.readlines()
> intcount = 0
> newcontent  =[]
> for line in readlines:
>     print line.strip()   # remove leading and trailing whitspace's incl. \n
>     self.contentlist[intcount].set(repr(line.strip))
>     intcount = intcount + 1
> 
> But all the entry fields are filled with these and not the text:
> 
> <built-in method strip of str object at 0x009983B0>
> 
> I'm not sure what else to do here...
> 
> any ideas?

I think I got the jist of it - readlines is a list, which holds all
the text, and so I also iterate over readlines and push that content
in thus:

self.contentlist[intcount].set(readlines[intcount])

Adam

-- 
http://www.monkeez.org
PGP key: 0x7111B833


More information about the Tutor mailing list