display in tkinter code example

Example 1: 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 2: how to create a label in tkinter

#How to create a label in Tkinter

from tkinter import *

#First create a screen
new_window = Tk()
new_window.title("My Python Project")
new_window.geometry("300x250")

Label(new_window, text = "Hello World").pack()
#Label : Tells Python that a label is being created
#new_window : whatever screen you want the label to be shown on ; name the screen whatever you like
#text : this tells that there is text being typed in the label
#.pack() : shows the label on the screen