im trying to use the .get() method to get all the text from a tkinter text widget. the code im using is text = root.textwidget.get(1,end) i get the error "name error: global name 'end' is not defined"

is there a word specficly for the end of the text or am i going about this the wrong way?

edit: ok all i had to do was change end to END. But now the error is "TclError Bad text index "1""

Recommended Answers

All 3 Replies

I think you have to use either END or 'end' and 1.0 for line.column.

yep that was it i figured it out myself but didnt get round to replying to this yet. i do have another problem though. One of the functions i have for the program runs through twice when the program starts (because it is the command of 2 buttons) but then it doesn't run after that when i press the buttons that have this function as their command. Either that or the shell doesn't display any print statements after the initial 2 runs (which is possible because it doesn't display the output of commands i type directly into it) AND the function isnt working properly and therefore doesn't display any output on the GUI either. Any common mistakes that cause this or should i post my code and if so what bits because the program is quite large (well by my standards)

yep, let's see your code, or see if you can repeat your problems with a shorter code. I am learning myself to code with the Tkinter GUI toolkit right now in my science class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.