Save user input from tkinter to a variable and check its content
The simplest solution is to make string
global:
def printtext(): global e global string string = e.get() text.insert(INSERT, string)
When you do that, other parts of your code can now access the value in string
.
This isn't the best solution, because excessive use of global variables makes a program hard to understand. The best solution is to take an object-oriented approach where you have an "application" object, and one of the attributes of that object would be something like "self.current_string".
For an example of how I recommend you structure your program, see https://stackoverflow.com/a/17470842/7432