[Tutor] Saving Entry fields in Tkinter

Ewald Ertl ewald.ertl at hartter.com
Tue Mar 1 12:52:57 CET 2005


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 :
---------------------------------------------------------------------------------------------

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:ewald.ertl at trinomic.com
A-7400 Oberwart         http://www.trinomic.com         mailto:ewald.ertl at hartter.com



More information about the Tutor mailing list