Insert string from file to TextArea Tkinter Python -


def isidatafile(self,namafile):     isifile = open(namafile)     content = isifile.read().lower()     words = re.findall('\w+',content)      print words      self.textfile.delete('1.0',end)     in words:         self.textfile.insert('1.0',i+"\n")      isifile.close() 

i wanna print string file .txt textarea (tkinter gui). example, string

"ular melingkar, lalu terbang. harimau berjalan di atas air. eh, kenapa hujan atas? bukan sungai mendaki" 

but, when insert string textarea, result :

>>> mendaki, sungai, bukan, atas, hujan, kenapa, eh, air, atas, di, berjalan, harimau, terbang, lalu, melingkar, ular. 

it look, somehow, reverse.

the reason order of words reversing inserting each word @ beginning:

    self.textfile.insert('1.0',i+"\n") 

i take words , build single string, example:

words = " ".join(words) 

and insert @ once instead of within for-loop.

the other option perform each insert within for-loop @ end, rather beginning:

for word in words:     self.textfile.insert(end, word) 

Popular posts from this blog