New App! EbookReader 3.0

This time we are going to make a new project from scratch. We are gonna make another sort of ebook reader, but this time will be just a reader (from the app), while you can modify the content from the script only. This is the code:

import tkinter as tk
import tkinter.ttk as ttk


CHAPTERS = (
"""Prerequisiti

- Turismo
- Effetti economici, sociali ed ambientali
- prodotto turistico
- prodotto turistico esperienza emozione
""",

"""Competenze

Adeguare e organizzare la produzione e la vendita in relazione alla domanda dei mercati, valorizzando i prodotti tipici; utilizzare le reti e gli strumenti informatici nelle attività di studio, ricerca e approfondimento disciplinare; redigere relazioni tecniche e documentare le attività industriali e di gruppo relative a situazioni professionali.
""",
"""Contenuti
...""")

def print_something(*args):
	tx.delete("0.0", tk.END)
	tx.insert("0.0", CHAPTERS[l.index(v.get())-1])

l = ["Argomenti"]
for c in CHAPTERS:
	l.append(c.split("\n", 1)[0])


root = tk.Tk()
v = tk.StringVar()
om = ttk.OptionMenu(root, v, *l)
v.set("Scegli")
v.trace("w", print_something)
om.pack()
om.focus()
tx = tk.Text(root)
tx.pack()

root.mainloop()

It derives from the last post about OptionMenu widget from tkinter. I had this idea of using it to read our contents through a menu, instead of a listbox, like I did for another similar project. This wants to be simple and neat. This is the start. We’re are gonna implement it with other features in a future post (or in future posts).

As you can see, there is nothing new apparently from the app of the last post, but the code is different. Now you can add the chapters and automatically the OptionMenu will add a voice to its items, so that your workflow will be more fast.

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.