from tkinter import *
import webbrowser
def click_button():
file_path = entry.get()
htmlcode = "<html>" + "\r\n"
htmlcode += "<head>" +"\r\n"
htmlcode += "</head>" +"\r\n"
htmlcode += '<body style="'+f"background-image: url('{file_path}')"+'"'+">"+"\r\n"
htmlcode += "</body>"+"\r\n"
htmlcode += "</html>"+"\r\n"
text_editor.delete(1.0,END)
text_editor.insert(END, htmlcode)
text_file = open("output.html", "w")
text_file.write(htmlcode)
text_file.close()
def click_button_2():
webbrowser.open("output.html")
root = Tk()
root.title("Генератор гипертекста")
root.geometry("500x500")
label = Label(text="Путь к изображению")
label.place(x=0,y=25)
entry = Entry()
entry.insert(0, "test.jpg")
entry.place(x=0,y=50,width=250)
text_editor = Text(height=10, wrap="word")
text_editor.place(x=0,y=100)
btn = Button(text="Сгенерировать html", command=click_button)
btn.place(x=0,y=0)
btn2 = Button(text="Запустить в браузере", command=click_button_2)
btn2.place(x=150,y=0)
root.mainloop()
|