Presentation Html Page with Python and Javascript

With this script you can create easily an html page with a presentation with just text, using python

import os

html = """<!doctype html>
<html>
<head>
<style>
body{
	background-color: #dfdfdf;
}
.box {
	display: block;
	text-align: center;
	width: window.innerWidth;
	padding: 30px 50px;
	background-color: darkblue;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
	border: 1px solid rgba(0, 0, 0, .3);
	border-radius: 20px;
	text-shadow: 0 2px 2px rgba(0, 0, 0, .1);
	font-family: Arial, sans-serif;
	font-size: 40px;
	color: white;
}
</style>
</head>
<body>

<div id="impress">
<script>

	function slide(x){
		let body = document.querySelector("body")
		let createDiv = document.createElement("div");
		createDiv.classList.add("box");
		let p = document.createElement("p");
		let text = document.createTextNode(x);
		p.append(text);
		createDiv.append(p);
		body.append(createDiv);
	}

<!-- here will go the text for the slides, divided by the \n -->
slides = `[[[slides]]]`
slides = slides.split("\\n");

for (s in slides){
	slide(slides[s]);
}



</script>



</div>


</body>
"""

slides = """IL BUSINESS plan
Il business plan è un documento che mostra la fattibilità di un'idea di business
Può riguardare il lancio di un nuovo prodotto o di una nuova azienda
Si compone di tre parti: La sintesi, l'esposizione del progetto e la valutazione
Nella sintesi, in modo sommario, si indica l'idea imprenditoriale, i soggetti che hanno dato vita all'iniziativa, la qualità, il target, la localizzazione dell'impresa e le motivazioni che hanno portato alla definizione del progetto.
"""

html = html.replace("[[[slides]]]", slides)

import tkinter as tk

def save(event):
	filename = entry.get() + ".html"
	with open(filename, "w", encoding="utf-8") as file:
		file.write(html)
	os.startfile(filename)



root = tk.Tk()
entry = tk.Entry(root)
entry.grid(row=0, column=1)
entry.focus()
label = tk.Label(root, text="Insert the name of the html file for the presentation")
label.grid(row=1, column=0)

entry.bind("<Return>", save)
root.mainloop()

The output


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts