
Here, we are creating a classical newspaper using tkinter Python. This newspaper will look like we read at home daily. We are using the Tkinter module for GUI purposes and will show text and images to tell any news to the reader.
Code
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Newspaper") root.geometry("1000x1000") def from_100(text1): my_text = "" for i in range(len(text1)): my_text += text1[i] if i != 0 and i % 100 == 0: my_text += "\n" return my_text text = [] photo = [] for i in range(0, 3): with open(f'{i + 1}.txt') as f: texts = f.read() text.append(from_100(texts)) image = Image.open(f"{i + 1}.png") image = image.resize((255, 200), Image.ANTIALIAS) photo.append(ImageTk.PhotoImage(image)) f0 = Frame(root, width=800, height=700) Label(f0, text="My Classical News Paper", font="lucida 33 bold").pack() Label(f0, text="copyassignment.com", font="lucida 13 bold").pack() f0.pack() f1 = Frame(root, width=900, height=200, borderwidth=6, relief=SUNKEN) Label(f1, text=text[0], padx=22, pady=22).pack(side="left") Label(f1, image=photo[0], anchor="e").pack() f1.pack(anchor="w") f2 = Frame(root, width=900, height=200, pady=10, borderwidth=6, relief=SUNKEN) Label(f2, text=text[1], padx=22, pady=22).pack(side="left") Label(f2, image=photo[1], anchor="e").pack() f2.pack(anchor="w") f3 = Frame(root, width=900, height=200, borderwidth=6, relief=SUNKEN) Label(f3, text=text[2], padx=22, pady=22).pack(side="left") Label(f3, image=photo[2], anchor="e").pack() f3.pack(anchor="w") root.mainloop()
Output
Also Read:
The system of the binary conversion
The binary number system defines a number in a binary system. You only find the number in a two-number system the 1 and the 0. The binary number system is an…
What is web development for beginners?
Introduction In web development, we refer to website so web development refers to website development. “Web” word has been taken from the spider’s web because of the analogy that like a…
Guide to Proxy Servers: How They Work and Why You Need Them?
What is a web proxy? During our college days, we often heard the term “proxy” which referred to the act of someone else marking our attendance, allowing us to be present…
Continue Reading Guide to Proxy Servers: How They Work and Why You Need Them?
Python | Check Armstrong Number using for loop
An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. Consider 153. It has 3 digits,…
Continue Reading Python | Check Armstrong Number using for loop
Python | Factorial of a number using for loop
The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined to be…
Continue Reading Python | Factorial of a number using for loop
Link in bio
Python Mega Course 2023 Radha Krishna Python Code