Tk – Window Demo

from tkinter import *

# Create window

root=Tk()

# Window title

root.title("Window Demo")

# Adjust window size according widget

root.propagate(1)

# Window background color

root.configure(background='silver')

'''

fg - foreground color - text color
bg background color

'''

# Crete Label objects

lblgm=Label(root,text="Good Evening",fg='green',bg='silver',font="Arial 25 bold")
lbleve=Label(root,text="Good Morning",fg='red',bg='silver',font="Tahoma 15 bold")

# Include label objects in window

lblgm.pack()
lbleve.pack()

root.mainloop()

Output

Tk

Published by Python programming examples for beginners

Abhay Gadkari is an IT professional having around experience of 20+ years in IT industry. He worked on web technologies and databases with Insurance and ERP projects.