'Python, i want to open a window that shows the content of a txt file with color formating
First of all im a beginner. So please, go easy on me :) this is the code i have written:
import os
from inspect import getsourcefile
from tkinter import *
CurrentPath=(os.path.dirname(getsourcefile(lambda:0)))
os.chdir(CurrentPath)
with open ("AufgabenReminder/AufgabenReminder.txt", "r") as myfile:
data = myfile.read()
win= Tk()
win.title('AufgabenReminder')
win.geometry("%dx%d+0+0" % (win.winfo_screenwidth(), win.winfo_screenheight()))
lab= Label(win, text= data, font=('Time New Roman', 35), fg="red").pack()
win.mainloop()
What it does: It opens a window with the content of the given txt file but all in red and the text is not "interactable". What i want it to do: It opens a window and shows the content of the txt file with different parts in different colors and that the text is interactable, what i mean with that mark it with the mouse to copy it with ctrl + c
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
