Skip to main content

News Paper in Python Tkinter

 






from tkinter import *
from PIL import Image, ImageTk

a = Tk()
a.geometry("1000x1200")


# after 150 alphabet new line Function
def newline(text):
    new = ""
    for i in range(0 ,len(text)):
        new += text[i]
        if i%150==0 and i!=0:
            new+= "\n"
    return new



photos = []
texts = []
for i in range(0,3):
    with open(f"{i+1}.txt") as f:
     
        text = f.read()
        texts.append(newline(text))
       
       
    image = Image.open(f"{i+1}.png")
    image = image.resize((180,180),Image.ANTIALIAS)
    photos.append(ImageTk.PhotoImage(image))

f0 = Frame(a)
Label(f0,text="Behind the scene",font='Segoe-Script 30 bold').pack()
Label(f0,text="Chandigarh",font='Segoe-Script 10 bold').pack()
Label(f0,text="31 Dec 2021",font='cursive 12 bold').pack()
f0.pack()



f1 = Frame(a)

Label(f1,text=texts[0],font='cursive 7 bold',justify=CENTER).pack(side=RIGHT,anchor="ne",pady=10,padx=10)
Label(f1,image = photos[0]).pack(side=LEFT,anchor="nw",pady=30,padx=10)
f1.pack()

f2 = Frame(a)
Label(f2,text=texts[1],font='cursive 7 bold').pack(side=RIGHT,anchor="ne",pady=20,padx=20)
Label(f2,image = photos[1]).pack(side=LEFT,anchor="nw",pady=10,padx=10)
f2.pack()

f3 = Frame(a)
Label(f3,text=texts[2],font='cursive 7 bold',justify=CENTER).pack(side=LEFT,anchor="ne",pady=20,padx=20)
Label(f3,image = photos[2]).pack(side=RIGHT,anchor="nw",pady=10,padx=10)
f3.pack()

a.mainloop()


Comments