How to take input in a text widget and display the text in Tkinter?
Last updated Dec 31, 2021User data may be captured and shown on the screen in the GUI applications. Python Tkinter lets us do that using the Text widgets with the Text attributes and packages. The get () method is used to get the user's text input from the text widgets. The input range is used to define the input range that will be displayed on the screen.
In this post, we are going to learn how user input may be captured and shown on the screen
In the following code snippet, we'll create a Text widget, receive user input, and display the text.
Example
In the following code snippet, we'll create a Text widget, receive user input, and display the text. We're going to take the user input "I Love Python" and display it
from tkinter import * from tkinter import ttk win=Tk() win.geometry("700x350") def get_input(): label.config(text=""+text.get(1.0, "end-1c")) text=Text(win, width=80, height=15) text.insert(END, "") text.pack() b=ttk.Button(win, text="Print", command=get_input) b.pack() label=Label(win, text="", font=('Calibri 15')) label.pack() win.mainloop()
|
![]() |
Article Contributed By :
|
|
|
|
590 Views |