Python: Tkinter: Multi line scrolling entry box
Question: I would like to make a Tkinter window able to ask for a multi line entry (so
the user will add one or more lines of text) And then when we clic on the
button be able to retrieve the values entered by user for further use.

Until now I have this script:

    
    
    from Tkinter import *
    import ScrolledText
    
    class EntryDemo:
      def __init__(self, rootWin):
        #Create a entry and button to put in the root window
        self.textfield = ScrolledText(rootWin)
        #Add some text:
        self.textfield.delete(0,END)
        self.textfield.insert(0, "Change this text!")
        self.textfield.pack()
    
        self.button = Button(rootWin, text="Click Me!", command=self.clicked)
        self.button.pack()
    
    
    
      def clicked(self):
        print("Button was clicked!")
        eText = self.textfield.get()
        print("The Entry has the following text in it:", eText)
    
    
    #Create the main root window, instantiate the object, and run the main loop
    rootWin = Tk()
    #app = EntryDemo( rootWin )
    rootWin.mainloop()
    

But it didn't seem to work, A window appear with nothing inside. Could you
help me?

#########EDIT

New code:

    
    
    from Tkinter import *
    import ScrolledText
    
    class EntryDemo:
      def __init__(self, rootWin):
    
        self.textfield = ScrolledText.ScrolledText(rootWin)
        #Add some text:
        #self.textfield.delete(0,END)
        self.textfield.insert(INSERT, "Change this text!")
        self.textfield.pack()
    
        self.button = Button(rootWin, text="Click Me!", command=self.clicked)
        self.button.pack()
    
    
    
      def clicked(self):
        eText = self.textfield.get(1.0, END)
        print(eText)
    
    rootWin = Tk()
    app = EntryDemo( rootWin )
    rootWin.mainloop()
    

Sorry if it look like done with no effort by some down voters (even if I spent
more than a day on it) but the Multi line text entry is not exactly what we
can call well documented to learn by ourself.


Answer: Your first problem is that you commented out the `app = EntryDemo( rootWin )`
call, so you're not actually doing anything but creating a `Tk()` root window,
then starting its main loop.

If you fix that, your next problem is that you're trying to use the
`ScrolledText` module as if it were a class. You need the
`ScrolledText.ScrolledText` class.

If you fix that, your next problem is that you're trying to `delete` from an
empty text field, which is going to raise some kind of Tcl index error, and
then you're also trying to `insert` at position 0 in an empty text field,
which will raise the same error. There's no reason to do the `delete` at all,
and for the `insert` you probably want to use `INSERT` as the position.

You still have multiple problems after that, but fixing these three will get
your edit box up and displayed so you can start debugging everything else.

