What is a way to convert text to a string in Python 3.3.0
Question: Hi so i'm having a hard time getting Text from my program on Python to convert
to a string so i can write it to a file without it just writing numbers in the
file. i put this code :

    
    
    from tkinter import *
    
    a = Tk()
    a.title("i need help")
    a.geometry("600x600")
    
    entryText = StringVar(None)
    
    codeEdit = Text(a)
    codeEdit.insert(END, "")
    codeEdit.pack(side='top')
    
    text = str(codeEdit)
    
    def setLoc():
        saveFile = open("DATA\Test.txt", "w")
        saveFile.write(text)
        saveFile.close()
    
    
        return 
    
    writeButton = Button(text="Write",command=setLoc)
    writeButton.pack(side='bottom')
    

so thats the code to write the obj locFile to the file Test.txt but when i
type something in the Text box on the program and hit the writButton it will
write to the file just not what i typed in it puts .50132192 so i wanted to
know how i could convert it to a String?


Answer: You need to use the `Text` widget's `get` method to get all of the text from
`'1.0'` (line 1, character 0) to `END`.

Here's a modified version of your code that does this in a `write_text`
function. I also added scroll bars and switched to using `grid` instead of
pack.

    
    
    from tkinter import *
    from tkinter import ttk
    
    def write_text():
        text = edit.get('1.0', END)
        with open("DATA/Test.txt", "w") as f:
            f.write(text)
    
    root = Tk()
    root.title("This May Help")
    root.geometry("600x600")
    
    edit = Text(root, width=80, height=25, wrap=NONE)
    edit.insert('1.0', '[enter text]')
    edit.grid(column=0, row=0, sticky=(N,W,E,S))
    
    yscroll = ttk.Scrollbar(root, orient=VERTICAL, command=edit.yview)
    yscroll.grid(column=1, row=0, sticky=(N,S))
    edit['yscrollcommand'] = yscroll.set
    
    xscroll = ttk.Scrollbar(root, orient=HORIZONTAL, command=edit.xview)
    xscroll.grid(column=0, row=1, sticky=(W,E))
    edit['xscrollcommand'] = xscroll.set
    
    write_button = Button(text="Write", command=write_text)
    write_button.grid(column=0, row=2)
    

