xxxxxxxxxx
from Tkinter import *
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
quote = """HAMLET: To be, or not to be--that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles
And by opposing end them. To die, to sleep--
No more--and by a sleep to say we end
The heartache, and the thousand natural shocks
That flesh is heir to. 'Tis a consummation
Devoutly to be wished."""
T.insert(END, quote)
mainloop()
xxxxxxxxxx
import tkinter as tk
# Create a function to handle button click event
def on_button_click():
user_input = entry.get() # Get text from the textbox
result_label.config(text=f"You entered: {user_input}")
# Create the main application window
root = tk.Tk()
root.title("Text Box Example")
# Create a label
label = tk.Label(root, text="Enter some text:")
label.pack()
# Create a textbox (Entry widget)
entry = tk.Entry(root)
entry.pack()
# Create a button
button = tk.Button(root, text="Submit", command=on_button_click)
button.pack()
# Create a label to display the result
result_label = tk.Label(root, text="")
result_label.pack()
# Start the main loop
root.mainloop()