{"id":106,"date":"2026-08-17T15:29:56","date_gmt":"2026-08-17T22:29:56","guid":{"rendered":"https:\/\/pointyhair.com\/?p=106"},"modified":"2026-08-17T16:23:52","modified_gmt":"2026-08-17T23:23:52","slug":"how-to-make-sound-effects-with-a-small-window-with-buttons-on-it","status":"publish","type":"post","link":"https:\/\/pointyhair.com\/index.php\/2026\/08\/17\/how-to-make-sound-effects-with-a-small-window-with-buttons-on-it\/","title":{"rendered":"How to make Sound effects with a small window with buttons on it"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Here are the scripts (Bash, Python and Tcl\/Tk) to get this done<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First the Python3 &amp; packages&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo apt install python3-pip<br>sudo apt install python3-tk<br>sudo apt install python3-pygame<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then we need the sound-effects, let&#8217;s put them in <code>Share\/Audio-Samples<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls\nair-horn-freesound_community-dj-airhorn-sound-39405.mp3\ncheer-dragon-studio-crowd-cheer-and-applause-406644.mp3\nding-freesound_community-ding-101492.mp3\nmagic-universfield-magic-03-278824.mp3\nsingingBowl-soundreality-bell-fx-410608.mp3\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now for the bash script to launch the app ( sound-effects.sh )<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 sound-effects.py<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to change the script to be executable: <code>chmod +x sound-effects.sh<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And finally the script itself ( sound-effects.py )<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import tkinter as tk\nimport pygame\n\ndef play_air_horn():\n    try:\n        pygame.mixer.music.load(\"Share\/Audio-Samples\/air-horn-freesound_community-dj-airhorn-sound-39405.mp3\")\n        pygame.mixer.music.play()\n        print(\"Playing audio file...\")\n    except pygame.error as e:\n        print(f\"Could not load audio file: {e}\")\ndef play_cheer():\n    try:\n        pygame.mixer.music.load(\"Share\/Audio-Samples\/cheer-dragon-studio-crowd-cheer-and-applause-406644.mp3\")\n        pygame.mixer.music.play()\n        print(\"Playing audio file...\")\n    except pygame.error as e:\n        print(f\"could not load audio file: {e}\")\ndef play_ding():\n    try:\n        pygame.mixer.music.load(\"Share\/Audio-Samples\/ding-freesound_community-ding-101492.mp3\")\n        pygame.mixer.music.play()\n        print(\"Playing audio file...\")\n    except pygame.error as e:\n        print(f\"could not load audio file: {e}\")\ndef play_magic():\n    try:\n        pygame.mixer.music.load(\"Share\/Audio-Samples\/magic-universfield-magic-03-278824.mp3\")\n        pygame.mixer.music.play()\n        print(\"Playing audio file...\")\n    except pygame.error as e:\n        print(f\"could not load audio file: {e}\")\ndef play_bell():\n    try:\n        pygame.mixer.music.load(\"Share\/Audio-Samples\/singingBowl-soundreality-bell-fx-410608.mp3\")\n        pygame.mixer.music.play()\n        print(\"Playing audio file...\")\n    except pygame.error as e:\n        print(f\"could not load audio file: {e}\")\n\n\n# Rest of the code remains the same\nroot = tk.Tk()\npygame.mixer.init()\n\nbutton = tk.Button(root, text=\"Air Horn\", command=play_air_horn).grid(row=0)\nbutton = tk.Button(root, text=\"Cheer\", command=play_cheer).grid(row=1)\nbutton = tk.Button(root, text=\"Ding\", command=play_ding).grid(row=2)\nbutton = tk.Button(root, text=\"Magic\", command=play_magic).grid(row=3)\nbutton = tk.Button(root, text=\"SingingBowl bell\", command=play_bell).grid(row=4)\n#button.pack(pady=20)\n\nroot.mainloop()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"243\" height=\"302\" src=\"https:\/\/pointyhair.com\/wp-content\/uploads\/2026\/08\/ksnip_20260817-161902.png\" alt=\"Ksnip 20260817\" class=\"wp-image-115\" srcset=\"https:\/\/pointyhair.com\/wp-content\/uploads\/2026\/08\/ksnip_20260817-161902.png 243w, https:\/\/pointyhair.com\/wp-content\/uploads\/2026\/08\/ksnip_20260817-161902-241x300.png 241w\" sizes=\"auto, (max-width: 243px) 100vw, 243px\" \/><figcaption class=\"wp-element-caption\">tk window<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Not the prettiest code, but in its simplicity it gets the point across &#8212; I wrote this to my wife trying to beat a five minute timer&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can launch the script, a window will pop up, with five buttons for the five sound effects. You can drag and drop the window to another screen, go on zoom, and just click on a sound effect when needed. The &#8220;app&#8221; does not consume multiple threads or lots of memory, you can let it run forever. If you need to suddenly stop a sound effect, just kill the app, by pressing the &#8220;X.&#8221; The key features of this exercise was that the dialog had to be small and moveable, and the buttons\/effects must be immediate (no loading programs).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nice enhancements:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Automatically build the list of buttons from the files in the directory<\/li>\n\n\n\n<li>Have a stop button without having to kill the app<\/li>\n\n\n\n<li>Have the window sizing<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Here are the scripts (Bash, Python and Tcl\/Tk) to get this done First the Python3 &amp; packages&#8230; sudo apt install python3-pipsudo apt install python3-tksudo apt install python3-pygame Then we need&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"How to make Sound effects with a small window with buttons on it - Pointyhair","description":"Here are the scripts (Bash, Python and Tcl\/Tk) to get this done First the Python3 &amp; packages... sudo apt install python3-pip sudo apt install python3-tk sud"},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":6,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":116,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions\/116"}],"wp:attachment":[{"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pointyhair.com\/index.php\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}