How to take text input in python tkinter code example

Example 1: print textbox value in tkinter

import tkinter as tk
root = tk.Tk()
root.geometry("400x240")

def getTextInput():
    result=textExample.get("1.0","end")
    print(result)

textExample=tk.Text(root, height=10)
textExample.pack()
btnRead=tk.Button(root, height=1, width=10, text="Read", 
                    command=getTextInput)

btnRead.pack()

root.mainloop()

Example 2: print textbox value in tkinter

result=textExample.get("1.0","end")
print(result)

Example 3: read value from entry tkinter

#ent is the name of the Entry
s = ent.get()

Tags:

Misc Example