{"id":333,"date":"2018-07-01T09:29:52","date_gmt":"2018-07-01T07:29:52","guid":{"rendered":"http:\/\/pythonprogramming.altervista.org\/?p=333"},"modified":"2021-03-10T10:32:34","modified_gmt":"2021-03-10T09:32:34","slug":"tkinter-12-listbox","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/tkinter-12-listbox\/","title":{"rendered":"Tkinter 11 &#8211; Listbox"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">The listbox in tkinter<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-12-listbox\/listbox\/\" rel=\"attachment wp-att-337\"><img loading=\"lazy\" decoding=\"async\" width=\"301\" height=\"273\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/listbox.png\" alt=\"\" class=\"wp-image-337\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A listbox is a text box in with there are items in each row, like in a grocery list. I will show you the use of listbox in tkinter trough an example. This is the 11th lesson, so you should know about tkinter, the button widget and the entry widget. If not, go to the end of this article and check for the previous lessons.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">An app to create a to do list in Python with Tkinter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To show you how to use the listbox, I will show you the code for a little app. In the video at the end of this article, I will explain the code, while I&#8217;m writing it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The code of the App<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the full code. I&#8217;ll explain it in the next video.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:default decode:true\">import tkinter as tk\n\n\ndef clicked():\n\tlistbox.insert(tk.END, content.get())\n\ndef delete():\n\tlistbox.delete(0, tk.END)\n\ndef delete_selected():\n\tlistbox.delete(tk.ANCHOR)\n\n# The window\nroot = tk.Tk()\nroot.title(\"List App\")\nroot.geometry(\"400x400\")\n\n# The entry to input the items\ncontent = tk.StringVar()\nentry = tk.Entry(root, textvariable=content)\nentry.pack()\n\n# The button to insert the item in the list\nbutton = tk.Button(root, text=\"Add Item\", command=clicked)\nbutton.pack()\n\n# the button to delete everything\nbutton_delete = tk.Button(text=\"Delete\", command=delete)\nbutton_delete.pack()\n\n# The button to delete only the selected item in the list\nbutton_delete_selected = tk.Button(text=\"Delete Selected\", command=delete_selected)\nbutton_delete_selected.pack()\n\n# The listbox\nlistbox = tk.Listbox(root)\nlistbox.pack()\n\nroot.mainloop()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">&nbsp;<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-31.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-31.png\" alt=\"\" class=\"wp-image-8852\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-31.png 800w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-31-320x240.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-31-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><figcaption>A window with three buttons and three relative function for the command event<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Using a class for the app<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We could use a class for this app to make a more mantainable code<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import tkinter as tk\n\n# LISTBOX\nclass Window:\n\n\tdef __init__(self):\n\t\tself.root = tk.Tk()\n\t\tself.root.title(\"List App\")\n\t\tself.root.geometry(\"400x400\")\n\t\tself.widgets()\n\n\tdef widgets(self):\n\t\t\"Widgets in order from top to bottom\"\n\t\tself.entry()\n\t\tself.buttons()\n\t\tself.listbox()\n\n\tdef entry(self):\n\t\t\"Here you input the items\"\n\t\tself.content = tk.StringVar()\n\t\tself.entry = tk.Entry(self.root, textvariable=self.content)\n\t\tself.entry.pack()\n\t\tself.entry.focus()\n\n\tdef buttons(self):\n\t\t\"Buttons to insert the items, delete all of them or the selected one\"\n\t\tself.button = tk.Button(self.root, text=\"Add Item\", command=self.insert_item)\n\t\tself.button.pack()\n\t\tself.button_delete = tk.Button(self.root, text=\"Delete\", command=self.delete)\n\t\tself.button_delete.pack()\n\t\tself.button_delete_selected = tk.Button(self.root, text=\"Delete Selected\", command=self.delete_selected)\n\t\tself.button_delete_selected.pack()\n\t\n\tdef listbox(self):\n\t\t\"The listbox with the items\"\n\t\tself.listbox = tk.Listbox(self.root)\n\t\tself.listbox.pack()\n\t\tself.root.mainloop()\n\n\tdef insert_item(self):\n\t\t\"The command to insert the item in the entry\"\n\t\tself.listbox.insert(tk.END, self.content.get())\n\t\tself.content.set(\"\")\n\n\tdef delete(self):\n\t\t\"Command to delete all items\"\n\t\tself.listbox.delete(0, tk.END)\n\n\tdef delete_selected(self):\n\t\t\"Command to delete only the selected item\"\n\t\tself.listbox.delete(tk.ANCHOR)\n\nWindow()<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-32.png\"><img loading=\"lazy\" decoding=\"async\" width=\"885\" height=\"656\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-32.png\" alt=\"\" class=\"wp-image-8856\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-32.png 885w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-32-320x237.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-32-768x569.png 768w\" sizes=\"auto, (max-width: 885px) 100vw, 885px\" \/><\/a><figcaption>The result is the same<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Video &#8211; part 1 and part 2<\/h2>\n\n\n<p><iframe loading=\"lazy\" title=\"Python and Tkinter - Listbox, how to add and delete items\" width=\"747\" height=\"560\" src=\"https:\/\/www.youtube.com\/embed\/Ea1LjAyqBs4?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\n\n\n<h2 class=\"wp-block-heading\">A better look to the GUI<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want, you can use ttk to make some nice buttons<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import tkinter as tk\nimport tkinter.ttk as ttk\n\n\n# LISTBOX\nclass Window:\n\n\tdef __init__(self):\n\t\tself.root = tk.Tk()\n\t\tself.root.title(\"List App\")\n\t\tself.root.geometry(\"400x400\")\n\t\tself.widgets()\n\n\tdef widgets(self):\n\t\t\"Widgets in order from top to bottom\"\n\t\tself.entry()\n\t\tself.buttons()\n\t\tself.listbox()\n\n\tdef entry(self):\n\t\t\"Here you input the items\"\n\t\tself.content = tk.StringVar()\n\t\tself.entry = ttk.Entry(self.root, textvariable=self.content)\n\t\tself.entry.pack()\n\t\tself.entry.focus()\n\n\tdef buttons(self):\n\t\t\"Buttons to insert the items, delete all of them or the selected one\"\n\t\tself.button = ttk.Button(self.root, text=\"Add Item\", command=self.insert_item)\n\t\tself.button.pack()\n\t\tself.button_delete = ttk.Button(self.root, text=\"Delete\", command=self.delete)\n\t\tself.button_delete.pack()\n\t\tself.button_delete_selected = ttk.Button(self.root, text=\"Delete Selected\", command=self.delete_selected)\n\t\tself.button_delete_selected.pack()\n\t\n\tdef listbox(self):\n\t\t\"The listbox with the items\"\n\t\tself.listbox = tk.Listbox(\n\t\t\tself.root)\n\t\tself.listbox.pack()\n\t\tself.root.mainloop()\n\n\tdef insert_item(self):\n\t\t\"The command to insert the item in the entry\"\n\t\tself.listbox.insert(tk.END, self.content.get())\n\t\tself.content.set(\"\")\n\n\tdef delete(self):\n\t\t\"Command to delete all items\"\n\t\tself.listbox.delete(0, tk.END)\n\n\tdef delete_selected(self):\n\t\t\"Command to delete only the selected item\"\n\t\tself.listbox.delete(tk.ANCHOR)\n\nWindow()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s what we got<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-33.png\"><img loading=\"lazy\" decoding=\"async\" width=\"402\" height=\"432\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-33.png\" alt=\"\" class=\"wp-image-8860\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-33.png 402w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-33-320x344.png 320w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/a><figcaption>Some nice buttons with ttk<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Save the entries<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this code there is a way to save the data into a file, so that when you close the window with a button at the bottom of the window, it will save the data in the listbox. When you will open the window again, the data will be still there.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:default decode:true\">import tkinter as tk\n\n\nroot = tk.Tk()\nroot.title(\"List App\")\nroot.geometry(\"400x400\")\n\ndef retrievedata():\n    \"Loads the data at the opening\"\n    global list_data\n    list_data = []\n    try:\n        with open(\"save.txt\", \"r\", encoding=\"utf-8\") as file:\n            for f in file:\n                listbox.insert(tk.END, f.strip())\n                list_data.append(f.strip())\n    print(list_data)\n    except:\n        pass\n\ndef clicked():\n    \"When click on a button it adds what is inside the entry box\"\n    global list_data\n    listbox.insert(tk.END, content.get())\n    list_data.append(content.get())\n\ndef delete():\n    \"Delete all the items in the list\"\n    global list_data\n    listbox.delete(0, tk.END)\n    list_data = []\n\ndef delete_selected():\n    \"Delete the selected file\"\n    global list_data\n    selected = listbox.get(listbox.curselection())\n    listbox.delete(tk.ANCHOR)\n    #index = list_data[list_data.index(selected)]\n    #print(index)\n    list_data.pop(list_data.index(selected))\n\ndef quit():\n    \"action performed when you click the button quit and save\"\n    global root\n    with open(\"save.txt\", \"w\", encoding=\"utf-8\") as file:\n        for d in list_data:\n\t    file.write(d + \"\\n\")\n    root.destroy()\n\n# LISTBOX - The building of the GUI\n\n# The entry\ncontent = tk.StringVar()\nentry = tk.Entry(root, textvariable=content)\nentry.pack()\n\n# The button to add items linked to the clicked() function\nbutton = tk.Button(root, text=\"Add Item\", command=clicked)\nbutton.pack()\n\n# the delete button, to delete all -&gt; delete()\nbutton_delete = tk.Button(text=\"Delete\", command=delete)\nbutton_delete.pack()\n\n# the button to delete only selected item\nbutton_delete_selected = tk.Button(text=\"Delete Selected\", command=delete_selected)\nbutton_delete_selected.pack()\n\n# The listbox\nlistbox = tk.Listbox(root)\nlistbox.pack()\n\n# the button to quit and save the data in the listbox so that they will stay\nbquit = tk.Button(root, text=\"Quit and save\", command=quit)\nbquit.pack()\n\n# the function to load the data saved previously\nretrievedata()\n\n# the built-in function to start the loop of the window\nroot.mainloop()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is how the window looks like. Remember to use the butto &#8220;Quit and save&#8221; to save the data.<\/p>\n\n\n\n<figure class=\"wp-block-image alignnone\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/lb2img.png\"><img loading=\"lazy\" decoding=\"async\" width=\"408\" height=\"436\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/lb2img.png\" alt=\"\" class=\"wp-image-1664\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/lb2img.png 408w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/lb2img-320x342.png 320w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/a><figcaption>window of the app to save lists items<\/figcaption><\/figure>\n\n\n\t<!----- pubblicit\u00e0-------- vedi h:\\ads\\codice_di_prima.txt per il codice che era qui --------------------->\r\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- Altervista-pythonprogramming-336X280 -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-4189782812829764\"\r\n     data-ad-slot=\"2548661001\"\r\n     data-ad-format=\"auto\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n<h4>Tkinter test for students<\/h4>\r\n\r\n\r\n<script>\r\nvar title = \"Tkinter posts\";\r\n\t\tvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-app-to-make-a-different-test-for-every-student-part-1\/\",\"Tk Test Marker I\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-testmaker-part-ii\/\",\"Tk Test Maker II\"],\t\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-tests-app-part-3\/\",\"Tk test Maker III\"]\r\n];\r\n\t\t\r\n\t<\/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>\r\n\t\r\n\r\n<h4>Tkinter articles<\/h4>\r\n<!-- calculator with memo -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/free-calculator-memo-with-tkinter-support-markdown-to-html-saving-too\/\">\r\n<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/03\/calcmemopy_banner.png\" width=\"100%\"><\/a>\r\n<script>\r\nvar title = \"Tkinter posts\";\r\n\t\tvar links = [\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/?p=5719&preview=true\",\"Presentation app with SVG files\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/png-joined-in-one-pdf-files\/\",\"Join png into pdf\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/free-app-imgslide-3-1-slide-images-and-join-them-into-a-pdf\/\",\"ImageSlider 3.1\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-to-show-svg-files-svgslider-1-0\/\",\"SVGSlider 1.0\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/imageslider-3-0-tkinter-app-to-show-images-like-in-a-presentation\/\",\"ImageSlider 3.0\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-shows-an-svg-file\/\",\"SVG in tkinter\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-tests-maker-app-part-iv-add-a-menu-with-tkinter\/\",\"Add a menu with tkinter\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/free-pdf-maker-app-with-python\/\",\"tkinter make pdf\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/calcpy-2-0-the-second-and-final-part-of-calculator\/\",\"Live coding Calculator app part 2\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/split-every-page-in-a-pdf-i-a-different-pdf\/\",\"Split a pdf in different files\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/python-calculator-from-skratch-part-1-calcpy\/\",\"Calculator from skratch p.1\"], \r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/python-and-tkinter-fully-working-listbox-to-do-app-for-skratch\/\",\"Tkinter ToDo App\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/copy-and-paste-tkinter-widget-code-app\/\",\"Copy and paste app for tkinter widgets\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/calcdoc-py-a-tkinter-app-to-memorize-operations\/\",\"calcdoc.py: a great calculator memo app\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-calculator-with-memo-of-operations\/\",\"Calculator + list of operations\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-smallest-calculator-ever\/\", \"Smallest calculator\"],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/python-gui-with-tkinter-labels-with-text-and-images\/\",\"Labels with images and text\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/a-toolbar-for-python-with-tkinter\/\",\"Toolbar in tkinter\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-grid-system-how-to-expand-a-button\/\",\"Fit Buttons to the Window\"],\r\n\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-application-launcher-python-gui\/\",\"Tkinter app Laucher\"],\r\n\t\t[\"https:\/\/pythonprogramming.altervista.org\/tkinter-and-how-to-add-an-image-to-a-button\/\", \"Image on a tkinter Button\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-imagebrowser-2-with-canvas\/\", \"Tkinter image browser 2 (canvas)\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-image-broswer\/\",\"Tkinter image browser (label)\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-to-make-pdf-fast-and-free-with-text-or-html\/\",\"Create PDF with Tkinter Text widget\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-app-to-evaluate-tests-part-1\/\",\"Tkinter App to Evaluate tests\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/simple-presentation-in-pure-python-while-you-learn-tkinter\/\",\"Presentation with Python\/tkinter\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-entry-widgets-example-make-a-shuffler-app\/\",\"Tkinter example: entry to shuffle lists\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/move-a-rectangle-with-text-inside-of-it-with-tkinter\/\",\"Moving a text with tkinter\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-and-ttk-the-option-menu-widget\/\",\"Tkinter's OptionMenu (and ttk)\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-app-to-watch-videos-with-live-coding\/\",\t\t\t\t\t\"Tkinter to watch videos\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/type-reader-app-in-python-pc-read-the-letters-you-type-tkinter\/\",\t\"Type Reader App\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/create-a-new-tkinter-widget-inputbox\/\",\t\t\t\t\t\t\t\"Create your Inputbox\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-open-a-new-window-and-just-one\/\", \t\t\t\t\t\t\"Open only one more window\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/a-simple-test-maker-with-python-and-tkinter\/\", \t\t\t\t\t\"Test maker with tkinter\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/my-personal-notepad-toggle-tkinter-fullscreen\/\",\t\t\t\t\t\"Ebook maker with tkinter\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/tkinter-and-listbox-1\/\", \t\t\t\t\t\t\t\t\t\t\t\"Tkinter & listbox 2019 - 1\"],\r\n['https:\/\/pythonprogramming.altervista.org\/tkinter-using-a-gui-graphic-user-interface-with-python-part-1\/', \t'Create a window'],\r\n['https:\/\/pythonprogramming.altervista.org\/tkinter-to-make-a-window-video-1\/', \t\t\t\t\t\t\t\t'Create a window part 2'],\r\n[\"https:\/\/pythonprogramming.altervista.org\/create-more-windows-with-tkinter\/\",\t\t\t\t\t\t\t\t\"More windows tkinter!\"],\r\n['https:\/\/pythonprogramming.altervista.org\/tkinter-part-2-binding\/', \t\t\t\t\t\t\t\t\t\t'Binding functions to key\/button '],\r\n\t\t\t[\"https:\/\/pythonprogramming.altervista.org\/all-tkinter-posts\/\",\">>>ALL TKINTER POSTS>>>\"]\r\n\t\t];\r\n\t\t\r\n\t<\/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\n\n\n<p class=\"wp-block-paragraph\">[hooops name=&#8221;all&#8221;]<\/p>\n","protected":false},"excerpt":{"rendered":"A listbox is a text box in with there are items in each row, like in a grocery list. I will show you the use of listbox in tkinter trough an example.\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-12-listbox\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":338,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[210,1,122,120,59,211,49,50],"tags":[74,119,79,52,118,4,328,51],"class_list":["post-333","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basics","category-examples","category-gui","category-listbox","category-lists","category-lists-basics","category-tkinter","category-video","tag-button","tag-entry","tag-graphic-user-interface","tag-gui","tag-listbox","tag-python","tag-save-data","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\/333","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=333"}],"version-history":[{"count":20,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":8861,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/333\/revisions\/8861"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/338"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}