{"id":4022,"date":"2019-10-24T13:55:02","date_gmt":"2019-10-24T11:55:02","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=4022"},"modified":"2019-10-24T13:55:02","modified_gmt":"2019-10-24T11:55:02","slug":"new-app-ebookreader-3-0","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/new-app-ebookreader-3-0\/","title":{"rendered":"New App! EbookReader 3.0"},"content":{"rendered":"<p>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:<\/p>\n<pre class=\"lang:default decode:true  \">import tkinter as tk\r\nimport tkinter.ttk as ttk\r\n\r\n\r\nCHAPTERS = (\r\n\"\"\"Prerequisiti\r\n\r\n- Turismo\r\n- Effetti economici, sociali ed ambientali\r\n- prodotto turistico\r\n- prodotto turistico esperienza emozione\r\n\"\"\",\r\n\r\n\"\"\"Competenze\r\n\r\nAdeguare 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\u00e0 di studio, ricerca e approfondimento disciplinare; redigere relazioni tecniche e documentare le attivit\u00e0 industriali e di gruppo relative a situazioni professionali.\r\n\"\"\",\r\n\"\"\"Contenuti\r\n...\"\"\")\r\n\r\ndef print_something(*args):\r\n\ttx.delete(\"0.0\", tk.END)\r\n\ttx.insert(\"0.0\", CHAPTERS[l.index(v.get())-1])\r\n\r\nl = [\"Argomenti\"]\r\nfor c in CHAPTERS:\r\n\tl.append(c.split(\"\\n\", 1)[0])\r\n\r\n\r\nroot = tk.Tk()\r\nv = tk.StringVar()\r\nom = ttk.OptionMenu(root, v, *l)\r\nv.set(\"Scegli\")\r\nv.trace(\"w\", print_something)\r\nom.pack()\r\nom.focus()\r\ntx = tk.Text(root)\r\ntx.pack()\r\n\r\nroot.mainloop()<\/pre>\n<p>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&#8217;re are gonna implement it with other features in a future post (or in future posts).<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/ebookreader3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4023\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/ebookreader3.png\" alt=\"\" width=\"646\" height=\"443\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/ebookreader3.png 646w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/ebookreader3-320x219.png 320w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/a><\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"Ebook reader made with tkinter, python, OptionMenu&#8230; \n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/new-app-ebookreader-3-0\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":4025,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,11,49],"tags":[124,553,604,51],"class_list":["post-4022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples","category-modules","category-tkinter","tag-app","tag-ebook","tag-optionmenu","tag-tkinter"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"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\/4022","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=4022"}],"version-history":[{"count":3,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4022\/revisions"}],"predecessor-version":[{"id":4033,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4022\/revisions\/4033"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/4025"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=4022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=4022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=4022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}