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:
Case conversion in python assignment expert
Hello and welcome, in this post we will explore all the methods of Python strings that are used for case conversion in Python assignment experts. We will see how to use…
Continue Reading Case conversion in python assignment expert
Complete Python Roadmap for Beginners in 2022
Welcome to Python Complete Roadmap for Beginners. Whether you’re just starting out with Python or have been striding ahead for a while now, it’s important to keep track of your skills.…
Continue Reading Complete Python Roadmap for Beginners in 2022
Calculator Program in Python | On Different IDEs
Welcome to copyassignment.com. In this tutorial, we are going to write a simple Calculator Program in Python and run it on different IDEs of python for creating a calculator we are…
Continue Reading Calculator Program in Python | On Different IDEs
Boruvka’s Algorithm in Python
Introduction In this blog post, we will learn how to code Boruvka’s Algorithm in Python. Algorithms are at the heart of computer science. They are expressed as a finite sequence of…
Game in Python Assignment Expert
Chat on WhatsApp for Assignment Help Chat on WhatsApp for Assignment Help
Guessing number in python assignment expert
Hello friends, here is the code for Guessing number in python assignment expert, you can check the code and you can run this code as well, we have already put this…
Continue Reading Guessing number in python assignment expert
File “I:/PycharmProjects/untitled1/Classical Newspaper Using Tkinter Python.py”, line 24
open(f'{i + 1}.txt’) as f:
^
SyntaxError: invalid syntax
copy and paste the code, it should work correctly, there is no problem in the code.
Traceback (most recent call last):
File “/Users/sedulous/PycharmProjects/Calculator_for_all/Newspaper.py”, line 21, in
with open(f'{i + 1}.txt’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘1.txt’
error msg
any idea how to revert?
I’m new to this and i just wanted to run it but like other comments, i have an error message :
“Traceback (most recent call last):
File “C:\Users\Max\PycharmProjects\pythonProject\Music_GUI\NewsPaper.py”, line 21, in
with open(f”{i + 1}.txt”) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘1.txt'”
I’ve copy/paste your code, but nothing change.
create one text file with this name