On Tue, 1 Mar 2005 12:52:57 +0100
Ewald Ertl <[EMAIL PROTECTED]> 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 

Or use the fileinput module:

var_list = []
for line in fileinput.input(filename):
    var = Tkinter.StringVar()
    var.set(line)
    var_list.append(var)

Best regards

Michael

> 
> on Tue, 1 Mar 2005 09:22:06 +0000  Adam Cripps <[EMAIL PROTECTED]> wrote :
> ---------------------------------------------------------------------------------------------
> 
> Adam Cripps > I'm writing an application which has rows of Entry fields 
> (created in
> Adam Cripps > a loop - see previous thread; and thanks guys!). All the 
> content of
> Adam Cripps > the Entry fields are accessed through self.contentlist[i].get()
> Adam Cripps > 
> Adam Cripps > Now I'm trying to save the content of those fields in a friendly
> Adam Cripps > format. I've used pickle in the past, but experienced problems 
> with
> Adam Cripps > pickling Tkinter widgets.
> Adam Cripps > 
> Adam Cripps > I'm saving using this method :- 
> Adam Cripps > 
> Adam Cripps > for i in self.contentlist:
> Adam Cripps >     saving = i.get() + "\n"
> Adam Cripps >     f.write(saving)
> Adam Cripps > f.close()
> Adam Cripps > 
> Adam Cripps > which creates a text file with each entry field separated with 
> a "\n". 
> Adam Cripps > 
> Adam Cripps > What would be a good way to open this file and re-populate the 
> entry
> Adam Cripps > fields with the content?  I'm not sure how to parse the text 
> according
> Adam Cripps > to the \n separator.
> Adam Cripps > 
> Adam Cripps > Am I going down the right path here? 
> Adam Cripps > 
> Adam Cripps > TIA
> Adam Cripps > Adam
> 
> 
> ------------------- end ----------------------
> 
> 
> -- 
> Ing. Ewald Ertl         HartterGruppe                   Phone : 
> +43-3352-33085-558
> trinomic Projektmanagement & Informationstechnik GmbH   Fax   : 
> +43-3352-33085-600
> Wiener Straße 41                                        mailto:[EMAIL 
> PROTECTED]
> A-7400 Oberwart         http://www.trinomic.com         mailto:[EMAIL 
> PROTECTED]
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to