{"id":3630,"date":"2019-09-15T12:10:19","date_gmt":"2019-09-15T10:10:19","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=3630"},"modified":"2019-10-04T21:28:56","modified_gmt":"2019-10-04T19:28:56","slug":"python-ebook-maker-update-1","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/python-ebook-maker-update-1\/","title":{"rendered":"Python ebook maker (updates page)"},"content":{"rendered":"<p>03\/10\/2019 &#8211; updated to v. 1.5 (menubar)<\/p>\n<p>04\/10\/2019 &#8211; updated to v. 1.5 (highlight code)<\/p>\n<h2>What is this?<\/h2>\n<p>This is a little project to show some <strong>tkinter<\/strong> features, but it can be also used to make something interesting. You can <strong>create<\/strong> different <strong>txt<\/strong> files from the app, <strong>edit<\/strong> the text, <strong>change<\/strong> their names, <strong>delete<\/strong> them, having the different files in a <strong>list<\/strong> on the right of the app and you can also <strong>convert<\/strong> them into an <strong>html<\/strong> page with all the text in the different files or a html page with the text of a single page. It accept <strong>plain text<\/strong> to wich you can add some symbols at the beginning of a line to make some sort of <strong>markup<\/strong> or use <strong>html tags<\/strong> directly. I am actually using it and I will add <strong>new features<\/strong> (like committing the files to a <strong>github<\/strong> repository as you save the files) in the <strong>future<\/strong>.<\/p>\n<p>Version 1.4c2<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/version_1_4ce.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3785\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/version_1_4ce.png\" alt=\"\" width=\"608\" height=\"323\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/version_1_4ce.png 608w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/version_1_4ce-320x170.png 320w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/a><\/p>\n<p>In version 1.42c3-user-edition added the ctrl+p to save the html page of a single txt file<\/p>\n<p>Download it in <a href=\"https:\/\/github.com\/formazione\/PyEbooks\">the githun repository<\/a>.<\/p>\n<h2>Final version post<\/h2>\n<p>Organize a complex ebook in simple txt files, add html tags and images with special characters, from simple txt files. This is the aim of this app. Another aim is to get better at knowing tkinter&#8217;s widgets and how to start making a GUI, from skratch. This is <strong>PyEbooksMaker<\/strong> or Python Ebooks Maker.<\/p>\n<p>In the last days we have seen how to make a sort of <strong>ebook make<\/strong>r, to organize our work with a simple app and then create an html file with all the work that could easily become an true ebook. There is an update to the final version with many new features, like you can see in the the following paragraph.<\/p>\n<h2>New features<\/h2>\n<p>I added some new features to the app:<\/p>\n<ul>\n<li>rename files (with the button or pressing F2)<\/li>\n<li>delete files<\/li>\n<li>chance to insert\n<ul>\n<li>H2 tag with *<\/li>\n<li>\u00a0H3 tag with ^<\/li>\n<li>images with # tag<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>So, now, it is almost a complete app, even if it is very rough and need to be refined.<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/ebook_app.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3632\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/ebook_app.png\" alt=\"\" width=\"852\" height=\"432\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/ebook_app.png 852w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/ebook_app-320x162.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/ebook_app-768x389.png 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/a><\/p>\n<p>This is the code, until now,:<\/p>\n<pre class=\"lang:default decode:true \"># pyem_1_4c2 - 25\/09\/2019 @ Giovanni Gatto\r\n# pyem_1_4c3_user_edition_26_set_2019_compiti\r\n# aggiunto ctrl+p per visualizza la singola pagina html generata\r\n# (si poteva fare col pulsante save page)\r\n\r\nimport tkinter as tk\r\nimport glob\r\nfrom time import sleep\r\nimport os\r\n\"\"\"\r\n1.2\r\nAdded ctrl+s &lt;Control+s&gt; to bind of text\r\nAdded label to editor\r\n1.3\r\nadded red symbol for rendering html\r\n1.4\r\nAdded way to save render single txt file\r\n\"\"\"\r\n\r\nclass Ebook:\r\n    def __init__(self, root):\r\n        \"\"\"Define window for the app\"\"\"\r\n        self.root = root\r\n        self.root.geometry(\"850x400\")\r\n        self.root[\"bg\"] = \"coral\"\r\n        self.menu()\r\n        self.editor()\r\n        self.root.bind(\"&lt;Control-b&gt;\", lambda x: self.save_ebook())\r\n\r\n    # Widgets on the left ===============|\r\n    def menu(self):\r\n        \"\"\"Listbox on the left with file names\"\"\"\r\n\r\n        self.menubar = tk.Menu(self.root)\r\n        self.menubar.add_command(label=\"Help\", command=self.help)\r\n        self.root.config(menu=self.menubar)\r\n\r\n        self.frame2 = tk.Frame(self.root)\r\n        self.frame2[\"bg\"] = \"coral\"\r\n        self.frame2.pack(side='left', fill=tk.Y)\r\n\r\n        self.button = tk.Button(self.frame2, text=\"Save\", command = self.save)\r\n        self.button.pack()\r\n        self.button_ebook = tk.Button(self.frame2, text=\"Save ebook\", command = self.save_ebook)\r\n        self.button_ebook.pack()\r\n\r\n        # Save only current page\r\n        self.button_page = tk.Button(self.frame2, text=\"Save page\", command = self.save_page)\r\n        self.button_page.pack()\r\n\r\n        # commit to git\r\n        # self.button_commit = tk.Button(self.frame2, text=\"Commit\", command = self.commit)\r\n        # self.button_commit.pack()\r\n\r\n        self.button_plus = tk.Button(self.frame2, text=\"+\", command =lambda: self.new_window(Win1))\r\n        self.button_plus.pack()\r\n\r\n        self.button_rename = tk.Button(self.frame2, text = \"Rename file\",\r\n            command= lambda: self.new_window(Rename))\r\n        self.button_rename.pack()\r\n\r\n        self.button_delete = tk.Button(self.frame2, text = \"delete file\",\r\n            command= lambda: self.delete_file())\r\n        self.button_delete.pack()\r\n\r\n        self.lab_help = tk.Label(self.frame2, text=\"Symbols:\\n-------\\n* = &lt;h2&gt;\\n^ = &lt;h3&gt;\\n# = &lt;img...\\n=&gt; = red\\n&lt;F2&gt; Rename\", bg=\"coral\")\r\n        self.lab_help.pack()\r\n\r\n        self.frame1 = tk.Frame(self.root)\r\n        self.frame1[\"bg\"] = \"coral\"\r\n        self.frame1.pack(side='left', fill=tk.Y)\r\n        self.lstb = tk.Listbox(self.frame1, width=30) # selectmode='multiple', exportselection=0)\r\n        self.lstb['bg'] = \"black\"\r\n        self.lstb['fg'] = 'gold'\r\n        self.lstb.pack(fill=tk.Y, expand=1)\r\n        self.lstb.bind(\"&lt;&lt;ListboxSelect&gt;&gt;\", lambda x: self.show_text_in_editor())\r\n        self.lstb.bind(\"&lt;F2&gt;\", lambda x: self.new_window(Rename))\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def new_window(self, _class):\r\n        self.new = tk.Toplevel(self.root)\r\n        _class(self.new)\r\n\r\n    def commit(self):\r\n        os.startfile(\"commit.bat\")\r\n\r\n    def help(self):\r\n        print(\"Press &lt;F2&gt; to rename files\")\r\n\r\n    \r\n    def rename(self, filename):\r\n\r\n        os.rename(self.filename, \"text\\\\\" + filename)\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n        self.lstb.delete(\"active\")\r\n        self.lstb.insert(self.files.index(\"text\\\\\" + filename), \"text\\\\\" + filename)\r\n\r\n    def new_chapter(self, filename):\r\n        self.new.destroy()\r\n        if not filename.endswith(\".txt\"):\r\n            filename += \".txt\"\r\n        #os.chdir(\"text\")\r\n        with open(\"text\\\\\" + filename, \"w\", encoding=\"utf-8\") as file:\r\n            file.write(\"\")\r\n        self.reload_list_files(filename)\r\n\r\n    def reload_list_files(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n        self.lstb.select_set(self.files.index(\"text\\\\\" + filename))\r\n\r\n    def reload_list_files_delete(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def delete_file(self):\r\n        for num in self.lstb.curselection():\r\n            os.remove(self.files[num])\r\n        self.reload_list_files_delete()\r\n\r\n    def save(self):\r\n        if self.text.get(\"1.0\", tk.END) != \"\":\r\n            with open(self.filename, \"w\", encoding=\"utf-8\") as file:\r\n                file.write(self.text.get(\"1.0\", tk.END))\r\n            self.label_file_name[\"text\"] += \"...saved\"\r\n\r\n    def save_ebook(self):\r\n        html = \"\"\r\n        with open(\"ebook.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            for file in self.files: # this is the name of each file\r\n                with open(file, \"r\", encoding=\"utf-8\") as singlefile:\r\n                    # ================= SYMBOL =&gt; HTML ==============\r\n                    html += self.html_convert(singlefile.read())\r\n            htmlfile.write(html)\r\n        self.label_file_name[\"text\"] += \"...Opening Ebook\"\r\n        os.startfile(\"ebook.html\")\r\n\r\n    def save_page(self):\r\n        \"\"\"Save a single page v. 1.4 23\/09\/2019 at 05:40\"\"\"\r\n        html = \"\"\r\n        current = self.lstb.get(tk.ACTIVE)[:-4] # The file selected without .txt\r\n        with open(f\"{current}.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            # opend the active (selected) item in the listbox\r\n            with open(f\"{current}.txt\", \"r\", encoding=\"utf-8\") as readfile:\r\n                read = readfile.read() # get the text of the active file\r\n                read = self.html_convert(read) # convert this text in html with *^=&gt;\r\n                htmlfile.write(read) # create the new file with the rendered text\r\n        self.label_file_name[\"text\"] += \"...page rendered\"\r\n        os.startfile(f\"{current}.html\")\r\n        # os.system(\"start ..\/index.html\")\r\n\r\n\r\n\r\n    def html_convert(self, text_to_render):\r\n        \"\"\"Convert to my Markup language\"\"\"\r\n        html = \"\"\r\n        text_to_render = text_to_render.split(\"\\n\")\r\n\r\n        for line in text_to_render:\r\n            if line != \"\":\r\n                if line[0] == \"*\":\r\n                    line = line.replace(\"*\",\"\")\r\n                    html += f\"&lt;h2&gt;{line}&lt;\/h2&gt;\"\r\n                elif line[0] == \"^\":\r\n                    line = line.replace(\"^\",\"\")\r\n                    html += f\"&lt;h3&gt;{line}&lt;\/h3&gt;\"\r\n                elif line[0] == \"#\":\r\n                    line = line.replace(\"#\",\"\")\r\n                    if line.startswith(\"http\"):\r\n                        html += f\"&lt;img src='{line}' width='100%'&gt;&lt;br&gt;\"\r\n                    else:                \r\n                        html += f\"&lt;img src='img\\\\{line}' width='100%'&gt;&lt;br&gt;\"\r\n                elif line[0] == \"=\" and line[1]== \"&gt;\":\r\n                    line = line.replace(\"=&gt;\", \"\")\r\n                    html += f\"&lt;span style='color:red'&gt;{line}&lt;\/span&gt;\"\r\n                else:\r\n                    html += f\"&lt;p&gt;{line}&lt;\/p&gt;\"\r\n        return html\r\n\r\n    def show_text_in_editor(self):\r\n        \"\"\"Shows text of selected file in the editor\"\"\"\r\n        if not self.lstb.curselection() is ():\r\n            index = self.lstb.curselection()[0]\r\n            self.filename = self.files[index] # instead of self.lstb.get(index)\r\n            with open(self.filename, \"r\", encoding=\"utf-8\") as file:\r\n                content = file.read()\r\n            self.text.delete(\"1.0\", tk.END)\r\n            self.text.insert(tk.END, content)\r\n            self.label_file_name['text'] = self.filename\r\n\r\n    def editor(self):\r\n        \"\"\"The text where you can write\"\"\"\r\n        self.label_file_name = tk.Label(self.root, text=\"Editor - choose a file on the left\")\r\n        self.label_file_name.pack()\r\n        self.text = tk.Text(self.root, wrap=tk.WORD)\r\n        self.text['bg'] = \"darkgreen\"\r\n        self.text['fg'] = 'white'\r\n        self.text['font'] = \"Arial 24\"\r\n        self.text.pack(fill=tk.Y, expand=1)\r\n        self.text.bind(\"&lt;Control-s&gt;\", lambda x: self.save())\r\n        self.text.bind(\"&lt;Control-p&gt;\", lambda x: self.save_page())\r\n\r\n\r\nclass Win1():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry = tk.Entry(self.root)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.new_chapter(self.entry.get()))\r\n\r\nclass Rename():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100+200+200\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry_var = tk.StringVar()\r\n        self.entry = tk.Entry(self.root, textvariable=self.entry_var)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry_var.set(app.filename.split(\"\\\\\")[1])\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.rename(self.entry.get()))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    # =============================== checks if folders exists &amp;\r\n                                   #= creates them if not\r\n    if \"text\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"text\")\r\n\r\n    if \"img\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"img\")\r\n\r\n    root = tk.Tk()\r\n    app = Ebook(root)\r\n    app.root.title(\"pyem_1_4c3_user_edition_26_set_2019_compiti\")\r\n    root.mainloop()<\/pre>\n<p>Create a text folder inside the folder where this file is. Create also and img folder in case you want to add images using the initial tag # in the line with the image file name.<\/p>\n<h2>The video with the app working<\/h2>\n<p><iframe loading=\"lazy\" title=\"Python ebook maker 5 (updates)\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/GiAAs2i1NeI?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>Updates<\/h2>\n<h2>1.42c3-user-edition<\/h2>\n<p>In version 1.42c3-user-edition added the ctrl+p to save the html page of a single txt file.<\/p>\n<h2>Update 1.4c2<\/h2>\n<h3>Save single page<\/h3>\n<p>Now you can save a single page (save page button). This page will be rendered in html and saved by itself into the text directory. I am using this in case I want to render a single page to use without the whole ebook in a site or in any different &#8216;places&#8217;. There are some future features that I could implement and that I use to automatically add this pages into a site of github.io.<\/p>\n<h3>Future: Commit to github<\/h3>\n<p>This is related to what I wrote in the previous paragraph. If you want to use it for you, you must change the address of the repository, of course. You need to adapt the code to your needs. I will try to make it usable by others, but for now you can ignore it (the buttons are commented).<\/p>\n<h3>Images<\/h3>\n<p>Now you can use the # symbol to add Internet addresses of images and not only names of files stored into the img folder.<\/p>\n<h3>Update 1.3<\/h3>\n<p>22.09.16<\/p>\n<ul>\n<li>creates folders text and img if not present<\/li>\n<li>new symbol =&gt; for red color<\/li>\n<li>ctrl + b shows the Ebook<\/li>\n<\/ul>\n<p>Control if text and img folder are present, if not it creates them (in the if __name__ == &#8220;__main__ &#8230;&#8221;)<\/p>\n<pre class=\"lang:default decode:true\">    if \"text\" in os.listdir():\r\n        print(\"text folder exists\")\r\n    else:\r\n        os.mkdir(\"text\")\r\n        print(\"text folder created\")\r\n    if \"img\" in os.listdir():\r\n        print(\"img folder exists\")\r\n    else:\r\n        os.mkdir(\"img\")\r\n        print(\"text folder created\")<\/pre>\n<p>Added a <strong>new symbol &#8220;=&gt;&#8221;<\/strong> that gives a red color to the text that follows it.<\/p>\n<p>The code is in the method save_ebook<\/p>\n<pre class=\"lang:default decode:true \">                        elif line[0] == \"=\" and line[1]== \"&gt;\":\r\n                            line = line.replace(\"=&gt;\", \"\")\r\n                            html += f\"&lt;span style='color:red'&gt;{line}&lt;\/span&gt;\"<\/pre>\n<p>I added the instruction on the left<\/p>\n<pre class=\"lang:default decode:true \">self.lab_help = tk.Label(self.frame2, text=\"Symbols:\\n-------\\n* = &lt;h2&gt;\\n^ = &lt;h3&gt;\\n# = &lt;img...\\n=&gt; = red\", bg=\"coral\")<\/pre>\n<p>Now with ctrl + b you can create the ebook without using the button on the left.<\/p>\n<p>This line of code does the job in the last line of the __init__ method of the class Ebook<\/p>\n<pre class=\"lang:default decode:true \">        self.root.bind(\"&lt;Control-b&gt;\", lambda x: self.save_ebook())<\/pre>\n<p>&nbsp;<\/p>\n<h3>Update 1.2<\/h3>\n<p>22.09.2019 &#8211; Added the wrap = tk.Word to the arguments of<\/p>\n<pre class=\"lang:default decode:true \">self.text = tk.Text(self.root, wrap=tk.WORD)<\/pre>\n<p>to make the words to to the next line without splitting them in a weird way.<\/p>\n<h2>Update 1.5<\/h2>\n<p>I added a menubar, instead of the buttons on the left side of the window.<\/p>\n<pre class=\"lang:default decode:true \">        self.menubar = tk.Menu(self.root)\r\n        self.menubar.add_command(label=\"[ + ]\", command = lambda: self.new_window(Win1))\r\n        self.menubar.add_command(label=\"[ Delete ]\", command= lambda: self.delete_file())\r\n        self.menubar.add_command(label=\"[ Rename ]\", command= lambda: self.new_window(Rename))\r\n        self.menubar.add_command(label=\"[ Page ]\", command = self.save_page)\r\n        self.menubar.add_command(label=\"[ Ebook ]\", command = self.save_ebook)\r\n        self.menubar.add_command(label=\"[ SAVE ]\", command = self.save)       \r\n        self.menubar.add_command(label=\"[ Help ]\", command= lambda: self.new_window(Help))\r\n        self.root.config(menu=self.menubar)<\/pre>\n<p>This is how the window looks now (prettier and with more space for the text and list of files).<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/pyem1_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3887\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/pyem1_5.png\" alt=\"\" width=\"852\" height=\"452\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/pyem1_5.png 852w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/pyem1_5-320x170.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/09\/pyem1_5-768x407.png 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/a><\/p>\n<p>The code of version 1.5<\/p>\n<pre class=\"lang:default decode:true\"># pyem_1_4c2 - 25\/09\/2019 @ Giovanni Gatto\r\n# pyem_1_4c3_user_edition_26_set_2019_compiti\r\n# aggiunto ctrl+p per visualizza la singola pagina html generata\r\n# (si poteva fare col pulsante save page)\r\n# pyem2 - correct bug about renaming files\r\n# pyem2b - added at 196 and commented 195 (because of can't find filename) \r\n            # self.filename = self.lstb.get(index)\r\n# version 1.5 - added menubar\r\nimport tkinter as tk\r\nimport glob\r\nfrom time import sleep\r\nimport os\r\n\"\"\"\r\n1.2\r\nAdded ctrl+s &lt;Control+s&gt; to bind of text\r\nAdded label to editor\r\n1.3\r\nadded red symbol for rendering html\r\n1.4\r\nAdded way to save render single txt file\r\n\"\"\"\r\n\r\nclass Ebook:\r\n    def __init__(self, root):\r\n        \"\"\"Define window for the app\"\"\"\r\n        self.root = root\r\n        self.root.geometry(\"850x400\")\r\n        self.root[\"bg\"] = \"coral\"\r\n        self.menu()\r\n        self.editor()\r\n        self.root.bind(\"&lt;Control-b&gt;\", lambda x: self.save_ebook())\r\n\r\n    # Widgets on the left ===============|\r\n    def menu(self):\r\n        \"\"\"Listbox on the left with file names\"\"\"\r\n\r\n        # commit to git\r\n        # self.button_commit = tk.Button(self.frame2, text=\"Commit\", command = self.commit)\r\n        # self.button_commit.pack()\r\n\r\n        self.menubar = tk.Menu(self.root)\r\n        self.menubar.add_command(label=\"[ + ]\", command = lambda: self.new_window(Win1))\r\n        self.menubar.add_command(label=\"[ Delete ]\", command= lambda: self.delete_file())\r\n        self.menubar.add_command(label=\"[ Rename ]\", command= lambda: self.new_window(Rename))\r\n        self.menubar.add_command(label=\"[ Page ]\", command = self.save_page)\r\n        self.menubar.add_command(label=\"[ Ebook ]\", command = self.save_ebook)\r\n        self.menubar.add_command(label=\"[ SAVE ]\", command = self.save)       \r\n        self.menubar.add_command(label=\"[ Help ]\", command= lambda: self.new_window(Help))\r\n        self.root.config(menu=self.menubar)\r\n\r\n\r\n\r\n        self.frame1 = tk.Frame(self.root)\r\n        self.frame1[\"bg\"] = \"coral\"\r\n        self.frame1.pack(side='left', fill=tk.Y)\r\n        self.lstb = tk.Listbox(self.frame1, width=30) # selectmode='multiple', exportselection=0)\r\n        self.lstb['bg'] = \"black\"\r\n        self.lstb['fg'] = 'gold'\r\n        self.lstb.pack(fill=tk.Y, expand=1)\r\n        self.lstb.bind(\"&lt;&lt;ListboxSelect&gt;&gt;\", lambda x: self.show_text_in_editor())\r\n        self.lstb.bind(\"&lt;F2&gt;\", lambda x: self.new_window(Rename))\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def new_window(self, _class):\r\n        self.new = tk.Toplevel(self.root)\r\n        _class(self.new)\r\n\r\n    def commit(self):\r\n        os.startfile(\"commit.bat\")\r\n\r\n    def help(self):\r\n        print(\"Press &lt;F2&gt; to rename files\")\r\n\r\n    \r\n    def rename(self, filename):\r\n        self.lstb.delete(\"active\")\r\n        os.rename(self.filename, \"text\\\\\" + filename)\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n        self.reload_list_files(filename)\r\n        # self.lstb.insert(self.files.index(\"text\\\\\" + filename), \"text\\\\\" + filename)\r\n\r\n    def new_chapter(self, filename):\r\n        self.new.destroy()\r\n        if not filename.endswith(\".txt\"):\r\n            filename += \".txt\"\r\n        #os.chdir(\"text\")\r\n        with open(\"text\\\\\" + filename, \"w\", encoding=\"utf-8\") as file:\r\n            file.write(\"\")\r\n        self.reload_list_files(filename)\r\n\r\n    def reload_list_files(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n        self.lstb.select_set(self.files.index(\"text\\\\\" + filename))\r\n\r\n    def reload_list_files_delete(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def delete_file(self):\r\n        for num in self.lstb.curselection():\r\n            os.remove(self.files[num])\r\n        self.reload_list_files_delete()\r\n\r\n    def save(self):\r\n        if self.text.get(\"1.0\", tk.END) != \"\":\r\n            with open(self.filename, \"w\", encoding=\"utf-8\") as file:\r\n                file.write(self.text.get(\"1.0\", tk.END))\r\n            self.label_file_name[\"text\"] += \"...saved\"\r\n\r\n    def save_ebook(self):\r\n        html = \"\"\r\n        with open(\"ebook.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            for file in self.files: # this is the name of each file\r\n                with open(file, \"r\", encoding=\"utf-8\") as singlefile:\r\n                    # ================= SYMBOL =&gt; HTML ==============\r\n                    html += self.html_convert(singlefile.read())\r\n            htmlfile.write(html)\r\n        self.label_file_name[\"text\"] += \"...Opening Ebook\"\r\n        os.startfile(\"ebook.html\")\r\n\r\n    def save_page(self):\r\n        \"\"\"Save a single page v. 1.4 23\/09\/2019 at 05:40\"\"\"\r\n        self.save()\r\n        html = \"\"\r\n        current = self.lstb.get(tk.ACTIVE)[:-4] # The file selected without .txt\r\n        with open(f\"{current}.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            # opend the active (selected) item in the listbox\r\n            with open(f\"{current}.txt\", \"r\", encoding=\"utf-8\") as readfile:\r\n                read = readfile.read() # get the text of the active file\r\n                read = self.html_convert(read) # convert this text in html with *^=&gt;\r\n                htmlfile.write(read) # create the new file with the rendered text\r\n        self.label_file_name[\"text\"] += \"...page rendered\"\r\n        os.startfile(f\"{current}.html\")\r\n        # os.system(\"start ..\/index.html\")\r\n\r\n\r\n\r\n    def html_convert(self, text_to_render):\r\n        \"\"\"Convert to my Markup language\"\"\"\r\n        html = \"\"\r\n        text_to_render = text_to_render.split(\"\\n\")\r\n\r\n        for line in text_to_render:\r\n            if line != \"\":\r\n                if line[0] == \"*\":\r\n                    line = line.replace(\"*\",\"\")\r\n                    html += f\"&lt;h2&gt;{line}&lt;\/h2&gt;\"\r\n                elif line[0] == \"^\":\r\n                    line = line.replace(\"^\",\"\")\r\n                    html += f\"&lt;h3&gt;{line}&lt;\/h3&gt;\"\r\n                elif line[0] == \"\u00a7\":\r\n                    line = line.replace(\"\u00a7\",\"\")\r\n                    if line.startswith(\"http\"):\r\n                        html += f\"&lt;img src='{line}' width='100%'&gt;&lt;br&gt;\"\r\n                    else:                \r\n                        html += f\"&lt;img src='img\\\\{line}' width='100%'&gt;&lt;br&gt;\"\r\n                elif line[0] == \"=\" and line[1]== \"&gt;\":\r\n                    line = line.replace(\"=&gt;\", \"\")\r\n                    html += f\"&lt;span style='color:red'&gt;{line}&lt;\/span&gt;\"\r\n                else:\r\n                    html += f\"&lt;p&gt;{line}&lt;\/p&gt;\"\r\n        return html\r\n\r\n    def show_text_in_editor(self):\r\n        \"\"\"Shows text of selected file in the editor\"\"\"\r\n        \r\n        if not self.lstb.curselection() is ():\r\n            index = self.lstb.curselection()[0]\r\n            #self.filename = self.files[index] # instead of self.lstb.get(index)\r\n            self.filename = self.lstb.get(index)\r\n            with open(self.filename, \"r\", encoding=\"utf-8\") as file:\r\n                content = file.read()\r\n            self.text.delete(\"1.0\", tk.END)\r\n            self.text.insert(tk.END, content)\r\n            self.label_file_name['text'] = self.filename\r\n\r\n    def editor(self):\r\n        \"\"\"The text where you can write\"\"\"\r\n        self.label_file_name = tk.Label(self.root, text=\"Editor - choose a file on the left\")\r\n        self.label_file_name.pack()\r\n        self.text = tk.Text(self.root, wrap=tk.WORD)\r\n        self.text['bg'] = \"darkgreen\"\r\n        self.text['fg'] = 'white'\r\n        self.text['font'] = \"Arial 24\"\r\n        self.text.pack(fill=tk.Y, expand=1)\r\n        self.text.bind(\"&lt;Control-s&gt;\", lambda x: self.save())\r\n        self.text.bind(\"&lt;Control-p&gt;\", lambda x: self.save_page())\r\n\r\n\r\nclass Win1():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry = tk.Entry(self.root)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.new_chapter(self.entry.get()))\r\n\r\nclass Rename():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100+200+200\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry_var = tk.StringVar()\r\n        self.entry = tk.Entry(self.root, textvariable=self.entry_var)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry_var.set(app.filename.split(\"\\\\\")[1])\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.rename(self.entry.get()))\r\n\r\nclass Help():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.title(\"Shortcuts\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Shortcuts\")\r\n        self.label_file_name.pack()\r\n        istruzioni = \"\"\"* H2\r\n^ H3\r\n\u00a7 &lt;img src=...\r\n=&gt; red\r\n&lt;F2&gt; rename\"\"\"\r\n        self.text = tk.Text(self.root, width=30, height=6)\r\n        self.text.insert(\"1.0\", istruzioni)\r\n        self.text.pack(fill=tk.BOTH, expand=1)\r\n\r\nif __name__ == \"__main__\":\r\n    # =============================== checks if folders exists &amp;\r\n                                   #= creates them if not\r\n    if \"text\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"text\")\r\n\r\n    if \"img\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"img\")\r\n\r\n    root = tk.Tk()\r\n    app = Ebook(root)\r\n    app.root.title(\"pyem_1_5\")\r\n    root.mainloop()<\/pre>\n<h2>Update 1.6 &#8211; highlight code<\/h2>\n<p>I added a way to highlight the code (for Python) when you write the code like this<\/p>\n<blockquote><p>&gt;&gt;&gt; print(&#8220;Hello&#8221;)<\/p><\/blockquote>\n<pre class=\"lang:default decode:true \">    def highlight(self, code):\r\n        \"pass a string and it will be highlighted\"\r\n        # keywords to be colored in orange\r\n        kw = kwlist\r\n        for k in kw:\r\n            k = k + \" \"\r\n            code = code.replace(k, \"&lt;b style='color:orange'&gt;\" + k + \"&lt;\/b&gt;\")\r\n        code = code.replace(\"\\n\",\"&lt;br&gt;\")\r\n        #print(code)\r\n        # The 'indentation'\r\n        code = code.replace(\"\\t\", \"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\")\r\n        # functions to be clored in blue\r\n        _def= re.findall(\"\\w+\\(\", code)\r\n        for w in _def:\r\n            code = code.replace(w, \"&lt;b style='color:blue'&gt;\" + w[:-1] + \"&lt;\/b&gt;(\")\r\n        return code<\/pre>\n<p>In the html_converter I added this line (we need to import re and kwlist from keyword):<\/p>\n<pre class=\"lang:default decode:true\">import re\r\nfrom keyword import kwlist<\/pre>\n<pre class=\"lang:default decode:true\">                if line[0] == \"&gt;\":\r\n                    line = self.highlight(line) + \"&lt;br&gt;\"\r\n                    html += line<\/pre>\n<p>The whole code<\/p>\n<pre class=\"lang:default decode:true \"># pyem_1_4c2 - 25\/09\/2019 @ Giovanni Gatto\r\n# pyem_1_4c3_user_edition_26_set_2019_compiti\r\n# aggiunto ctrl+p per visualizza la singola pagina html generata\r\n# (si poteva fare col pulsante save page)\r\n# pyem2 - correct bug about renaming files\r\n# pyem2b - added at 196 and commented 195 (because of can't find filename) \r\n            # self.filename = self.lstb.get(index)\r\n# version 1.5 - added menubar\r\n# version 1.6 - added highlight function to higlight code\r\n# if a line starts with \"&gt;\"... so if there is &gt;&gt;&gt; ...\r\nimport tkinter as tk\r\nimport glob\r\nfrom time import sleep\r\nimport os\r\nimport re\r\nfrom keyword import kwlist\r\n\"\"\"\r\n1.2\r\nAdded ctrl+s &lt;Control+s&gt; to bind of text\r\nAdded label to editor\r\n1.3\r\nadded red symbol for rendering html\r\n1.4\r\nAdded way to save render single txt file\r\n\"\"\"\r\n\r\nclass Ebook:\r\n    def __init__(self, root):\r\n        \"\"\"Define window for the app\"\"\"\r\n        self.root = root\r\n        self.root.geometry(\"850x400\")\r\n        self.root[\"bg\"] = \"coral\"\r\n        self.menu()\r\n        self.editor()\r\n        self.root.bind(\"&lt;Control-b&gt;\", lambda x: self.save_ebook())\r\n\r\n    # Widgets on the left ===============|\r\n    def menu(self):\r\n        \"\"\"Listbox on the left with file names\"\"\"\r\n\r\n        # commit to git\r\n        # self.button_commit = tk.Button(self.frame2, text=\"Commit\", command = self.commit)\r\n        # self.button_commit.pack()\r\n\r\n        self.menubar = tk.Menu(self.root)\r\n        self.menubar.add_command(label=\"[ + ]\", command = lambda: self.new_window(Win1))\r\n        self.menubar.add_command(label=\"[ Delete ]\", command= lambda: self.delete_file())\r\n        self.menubar.add_command(label=\"[ Rename ]\", command= lambda: self.new_window(Rename))\r\n        self.menubar.add_command(label=\"[ Page ]\", command = self.save_page)\r\n        self.menubar.add_command(label=\"[ Ebook ]\", command = self.save_ebook)\r\n        self.menubar.add_command(label=\"[ SAVE ]\", command = self.save)       \r\n        self.menubar.add_command(label=\"[ Help ]\", command= lambda: self.new_window(Help))\r\n        self.root.config(menu=self.menubar)\r\n\r\n        self.frame1 = tk.Frame(self.root)\r\n        self.frame1[\"bg\"] = \"coral\"\r\n        self.frame1.pack(side='left', fill=tk.Y)\r\n        self.lstb = tk.Listbox(self.frame1, width=30) # selectmode='multiple', exportselection=0)\r\n        self.lstb['bg'] = \"black\"\r\n        self.lstb['fg'] = 'gold'\r\n        self.lstb.pack(fill=tk.Y, expand=1)\r\n        self.lstb.bind(\"&lt;&lt;ListboxSelect&gt;&gt;\", lambda x: self.show_text_in_editor())\r\n        self.lstb.bind(\"&lt;F2&gt;\", lambda x: self.new_window(Rename))\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def new_window(self, _class):\r\n        self.new = tk.Toplevel(self.root)\r\n        _class(self.new)\r\n\r\n    def commit(self):\r\n        os.startfile(\"commit.bat\")\r\n\r\n    def help(self):\r\n        print(\"Press &lt;F2&gt; to rename files\")\r\n\r\n    \r\n    def rename(self, filename):\r\n        self.lstb.delete(\"active\")\r\n        os.rename(self.filename, \"text\\\\\" + filename)\r\n        self.files = glob.glob(\"text\\\\*.txt\")\r\n        self.reload_list_files(filename)\r\n        # self.lstb.insert(self.files.index(\"text\\\\\" + filename), \"text\\\\\" + filename)\r\n\r\n    def new_chapter(self, filename):\r\n        self.new.destroy()\r\n        if not filename.endswith(\".txt\"):\r\n            filename += \".txt\"\r\n        #os.chdir(\"text\")\r\n        with open(\"text\\\\\" + filename, \"w\", encoding=\"utf-8\") as file:\r\n            file.write(\"\")\r\n        self.reload_list_files(filename)\r\n\r\n    def reload_list_files(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n        self.lstb.select_set(self.files.index(\"text\\\\\" + filename))\r\n\r\n    def reload_list_files_delete(self, filename=\"\"):\r\n        #os.chdir(\"..\")\r\n        self.lstb.delete(0, tk.END)\r\n        self.files = [f for f in glob.glob(\"text\\\\*txt\")]\r\n        for file in self.files:\r\n            self.lstb.insert(tk.END, file)\r\n\r\n    def delete_file(self):\r\n        for num in self.lstb.curselection():\r\n            os.remove(self.files[num])\r\n        self.reload_list_files_delete()\r\n\r\n    def save(self):\r\n        if self.text.get(\"1.0\", tk.END) != \"\":\r\n            with open(self.filename, \"w\", encoding=\"utf-8\") as file:\r\n                file.write(self.text.get(\"1.0\", tk.END))\r\n            self.label_file_name[\"text\"] += \"...saved\"\r\n\r\n    def save_ebook(self):\r\n        html = \"\"\r\n        with open(\"ebook.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            for file in self.files: # this is the name of each file\r\n                with open(file, \"r\", encoding=\"utf-8\") as singlefile:\r\n                    # ================= SYMBOL =&gt; HTML ==============\r\n                    html += self.html_convert(singlefile.read())\r\n            htmlfile.write(html)\r\n        self.label_file_name[\"text\"] += \"...Opening Ebook\"\r\n        os.startfile(\"ebook.html\")\r\n\r\n    def save_page(self):\r\n        \"\"\"Save a single page v. 1.4 23\/09\/2019 at 05:40\"\"\"\r\n        self.save()\r\n        html = \"\"\r\n        current = self.lstb.get(tk.ACTIVE)[:-4] # The file selected without .txt\r\n        with open(f\"{current}.html\", \"w\", encoding=\"utf-8\") as htmlfile:\r\n            # opend the active (selected) item in the listbox\r\n            with open(f\"{current}.txt\", \"r\", encoding=\"utf-8\") as readfile:\r\n                read = readfile.read() # get the text of the active file\r\n                read = self.html_convert(read) # convert this text in html with *^=&gt;\r\n                htmlfile.write(read) # create the new file with the rendered text\r\n        self.label_file_name[\"text\"] += \"...page rendered\"\r\n        os.startfile(f\"{current}.html\")\r\n        # os.system(\"start ..\/index.html\")\r\n\r\n    def highlight(self, code):\r\n        \"pass a string and it will be highlighted\"\r\n        # keywords to be colored in orange\r\n        kw = kwlist\r\n        for k in kw:\r\n            k = k + \" \"\r\n            code = code.replace(k, \"&lt;b style='color:orange'&gt;\" + k + \"&lt;\/b&gt;\")\r\n        code = code.replace(\"\\n\",\"&lt;br&gt;\")\r\n        #print(code)\r\n        # The 'indentation'\r\n        code = code.replace(\"\\t\", \"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\")\r\n        # functions to be clored in blue\r\n        _def= re.findall(\"\\w+\\(\", code)\r\n        for w in _def:\r\n            code = code.replace(w, \"&lt;b style='color:blue'&gt;\" + w[:-1] + \"&lt;\/b&gt;(\")\r\n        return code\r\n\r\n    def html_convert(self, text_to_render):\r\n        \"\"\"Convert to my Markup language\"\"\"\r\n        html = \"\"\r\n        text_to_render = text_to_render.split(\"\\n\")\r\n\r\n        for line in text_to_render:\r\n            if line != \"\":\r\n                if line[0] == \"&gt;\":\r\n                    line = self.highlight(line) + \"&lt;br&gt;\"\r\n                    html += line\r\n                elif line[0] == \"*\":\r\n                    line = line.replace(\"*\",\"\")\r\n                    html += f\"&lt;h2&gt;{line}&lt;\/h2&gt;\"\r\n                elif line[0] == \"^\":\r\n                    line = line.replace(\"^\",\"\")\r\n                    html += f\"&lt;h3&gt;{line}&lt;\/h3&gt;\"\r\n                elif line[0] == \"\u00a7\":\r\n                    line = line.replace(\"\u00a7\",\"\")\r\n                    if line.startswith(\"http\"):\r\n                        html += f\"&lt;img src='{line}' width='100%'&gt;&lt;br&gt;\"\r\n                    else:                \r\n                        html += f\"&lt;img src='img\\\\{line}' width='100%'&gt;&lt;br&gt;\"\r\n                elif line[0] == \"=\" and line[1]== \"&gt;\":\r\n                    line = line.replace(\"=&gt;\", \"\")\r\n                    html += f\"&lt;span style='color:red'&gt;{line}&lt;\/span&gt;\"\r\n                else:\r\n                    html += f\"&lt;p&gt;{line}&lt;\/p&gt;\"\r\n\r\n        #html = self.highlight(html)\r\n        return html\r\n\r\n    def show_text_in_editor(self):\r\n        \"\"\"Shows text of selected file in the editor\"\"\"\r\n        \r\n        if not self.lstb.curselection() is ():\r\n            index = self.lstb.curselection()[0]\r\n            #self.filename = self.files[index] # instead of self.lstb.get(index)\r\n            self.filename = self.lstb.get(index)\r\n            with open(self.filename, \"r\", encoding=\"utf-8\") as file:\r\n                content = file.read()\r\n            self.text.delete(\"1.0\", tk.END)\r\n            self.text.insert(tk.END, content)\r\n            self.label_file_name['text'] = self.filename\r\n\r\n    def editor(self):\r\n        \"\"\"The text where you can write\"\"\"\r\n        self.label_file_name = tk.Label(self.root, text=\"Editor - choose a file on the left\")\r\n        self.label_file_name.pack()\r\n        self.text = tk.Text(self.root, wrap=tk.WORD)\r\n        self.text['bg'] = \"darkgreen\"\r\n        self.text['fg'] = 'white'\r\n        self.text['font'] = \"Arial 24\"\r\n        self.text.pack(fill=tk.Y, expand=1)\r\n        self.text.bind(\"&lt;Control-s&gt;\", lambda x: self.save())\r\n        self.text.bind(\"&lt;Control-p&gt;\", lambda x: self.save_page())\r\n\r\n\r\nclass Win1():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry = tk.Entry(self.root)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.new_chapter(self.entry.get()))\r\n\r\nclass Rename():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.geometry(\"300x100+200+200\")\r\n        self.root.title(\"Insert new file name\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Enter a name\")\r\n        self.label_file_name.pack()\r\n        self.entry_var = tk.StringVar()\r\n        self.entry = tk.Entry(self.root, textvariable=self.entry_var)\r\n        self.entry.pack()\r\n        self.entry.focus()\r\n        self.entry_var.set(app.filename.split(\"\\\\\")[1])\r\n        self.entry.bind(\"&lt;Return&gt;\", lambda x: app.rename(self.entry.get()))\r\n\r\nclass Help():\r\n    def __init__(self, root):\r\n        self.root = root\r\n        self.root.title(\"Shortcuts\")\r\n        self.label_file_name = tk.Label(self.root, text=\"Shortcuts\")\r\n        self.label_file_name.pack()\r\n        istruzioni = \"\"\"* H2\r\n^ H3\r\n\u00a7 &lt;img src=...\r\n=&gt; red\r\n&lt;F2&gt; rename\r\n&gt; To highlight code\"\"\"\r\n        self.text = tk.Text(self.root, width=30, height=6)\r\n        self.text.insert(\"1.0\", istruzioni)\r\n        self.text.pack(fill=tk.BOTH, expand=1)\r\n\r\nif __name__ == \"__main__\":\r\n    # =============================== checks if folders exists &amp;\r\n                                   #= creates them if not\r\n    if \"text\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"text\")\r\n\r\n    if \"img\" in os.listdir():\r\n        pass\r\n    else:\r\n        os.mkdir(\"img\")\r\n\r\n    root = tk.Tk()\r\n    app = Ebook(root)\r\n    app.root.title(\"pyem_1_6\")\r\n    root.mainloop()<\/pre>\n<p>&nbsp;<\/p>\n<h2>What next?<\/h2>\n<p>I think I am going to add a voice in the menu to create pdf files from the txt files.<\/p>\n<script>\r\nvar title = \"PyBook the Ebook maker\";\r\nvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/my-personal-notepad-toggle-tkinter-fullscreen\/\",\"Pybook part 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/from-a-notepad-to-an-ebook-maker\/\",\"PyBook part 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-makes-ebooks-3-with-quick-recap\/\",\"PyBook part 3\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-ebooks-maker-4-save-files\/\",\"PyBook part 4\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-ebook-maker-4-1-finale\/\",\"PyBook part 4.1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-ebook-maker-update-1\/\",\"Updates until v. 1.6\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/py-ebook-v-1-8-make-ebooks-with-python-wip-dark-mode\/\",\"Version 1.8 Dark mode +-\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-how-to-hide-and-show-frames\/\",\"Hide n Show Frames\"]\r\n\t\t];\r\n<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"An update to the app to make ebooks through Python. We are at version 1.4c2\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/python-ebook-maker-update-1\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":3633,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[49],"tags":[552,573,52,572,4,565,51],"class_list":["post-3630","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tkinter","tag-ebooks","tag-ebooks-maker","tag-gui","tag-maker","tag-python","tag-render-html","tag-tkinter"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=3630"}],"version-history":[{"count":28,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3630\/revisions"}],"predecessor-version":[{"id":3903,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/3630\/revisions\/3903"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/3633"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=3630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=3630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=3630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}