tkinter text box code example

Example 1: tkinter textbox

import tkinter

textBox = tkinter.Enter(text="Placeholder text")

Example 2: creating a text box with tkinter py

import tkinter as tk
class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()
    def create_widgets(self):
        self.w3=tk.Entry(self.master)
        self.w3.pack(side='top')
        self.quit = tk.Button(self.master, text='quit', command=self.master.destroy).pack()
        self.test = tk.Button(self.master, text='print', command=self.get_text).pack()
    def get_text(self):
      print(self.w3.get())
root = tk.Tk()
app = Application(master=root)
app.mainloop()

Example 3: tkinter entry

from tkinter import *
root = Tk()
entry = Entry(root)
print(entry.get()) # Would print entry data in CL

Example 4: how to get tkinder to display text

import tkinter as tk

root = tk.Tk()
tk.Label(root, 
		 text="Red Text in Times Font",
		 fg = "red",
		 font = "Times").pack()
tk.Label(root, 
		 text="Green Text in Helvetica Font",
		 fg = "light green",
		 bg = "dark green",
		 font = "Helvetica 16 bold italic").pack()
tk.Label(root, 
		 text="Blue Text in Verdana bold",
		 fg = "blue",
		 bg = "yellow",
		 font = "Verdana 10 bold").pack()

root.mainloop()

Example 5: text widget get tkinter

contents = text.get(1.0, END)

Example 6: read value from entry tkinter

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