Type Error: get() takes at least 2 arguments, 1 given Type Error: get() takes at least 2 arguments, 1 given tkinter tkinter

Type Error: get() takes at least 2 arguments, 1 given


There is no widget called a "TextBox", so I don't know if you're talking about an Entry widget or a Text widget. The get method of the entry widget can be called without parameters, but the get method of the text widget requires two parameters. The two parameters are the starting and ending points of a region.

To get everything in a text widget, you should do it like this:

self.txtBox.get("1.0", "end-1c")

The "1.0" represents the first character, and "end-1c" represents the last character ("end") minus one character ("-1c") which will ignore the trailing newline that is always added by tkinter itself.


This old message from the python-tutor list might help. The two parameters are bizarre (to my mind: I am not a Tk expert) pointers, similar to string slicing but with the "pointers" being decimal numbers where the integer portion specifies the line and the decimal places specify the character numbers.