Need help with the get() method of a Text entry

Chad slug57_98 at
Thu Apr 12 22:28:37 CEST 2007

I have a simple little program that brings up asks the user to enter a
note, then is supposed to place that note into a text file when the
user hits the submit button.  However, when the user hits the submit
button, absolutely nothing happens.  IDLE doesn't give an error
message and the note is not entered into the text file.  For
troubleshooting puposes, I wanted to see if IDLE would at least print
the user's input; it doesn't do that either.  Can someone please help

Here is the code:

from Tkinter import *

class Application(Frame):
    """ GUI application that creates a story based on user input. """
    def __init__(self, master):
        """ Initialize Frame. """
        Frame.__init__(self, master)

    def create_widgets(self):
        """ Create widgets to get note information. """
        # create instruction label and text entry for notes
              text = "Notes"
              ).grid(row = 0, column = 0, columnspan = 2 )

        self.notes_ent = Text(self, width = 75, height = 10, wrap =
        self.notes_ent.grid(row = 2, column = 0 ,columnspan = 7,
rowspan = 3, sticky = W)
        create submit button
        text1 = StringVar(self)
        text1 = self.notes_ent.get(1.0, END)
                 text = "Add Note",
                 command = self.add_note(text1)
               ).grid(row = 1, column = 0, sticky = W)

    def add_note(self, text1):
        print text1
        text_file = open("write_it.txt", "a+")

root = Tk()
root.title("Mad Lib")
app = Application(root)

More information about the Python-list mailing list