Popular Python recipes tagged "meta:requires=tkinter"http://code.activestate.com/recipes/langs/python/tags/meta:requires=tkinter/2017-06-13T18:54:02-07:00ActiveState Code RecipesReload Tkinter application like a browser (Python) 2017-04-07T12:40:46-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580707-reload-tkinter-application-like-a-browser/ <p style="color: grey"> Python recipe 580707 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/reload/">reload</a>, <a href="/recipes/tags/reloading/">reloading</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 6. </p> <p><em>run_with_reloader:</em> Binding some hotkeys, for example control-r and control-R, the application is reloaded. It's the same behaviour than a browser. This code is useful for debugging.</p> <p>Some applications use a similar approach for easy development. For example flask and django reloads the application every time they observe a change in a file.</p> Tkinter Animated GIF (Python) 2017-04-10T11:27:05-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580708-tkinter-animated-gif/ <p style="color: grey"> Python recipe 580708 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/gif/">gif</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 10. </p> <p>Tkinter GIF in motion. It uses the "after" command of Tcl and PIL.</p> <p>Add path to GIF to make the example working.</p> Form with action like html forms. Tkinter (Python) 2017-04-07T13:01:45-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580714-form-with-action-like-html-forms-tkinter/ <p style="color: grey"> Python recipe 580714 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 14. </p> <p>Create forms using Tkinter with an associated action in the same way we do with HTML.</p> Space Assault (Python) 2016-04-06T23:31:28-07:00Tage Burnetthttp://code.activestate.com/recipes/users/4193902/http://code.activestate.com/recipes/580636-space-assault/ <p style="color: grey"> Python recipe 580636 by <a href="/recipes/users/4193902/">Tage Burnett</a> (<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This is a game I created on Python without the use of Pygame</p> chroma (Python) 2016-05-30T11:48:10-07:00aaahttp://code.activestate.com/recipes/users/4194184/http://code.activestate.com/recipes/580671-chroma/ <p style="color: grey"> Python recipe 580671 by <a href="/recipes/users/4194184/">aaa</a> (<a href="/recipes/tags/2d/">2d</a>, <a href="/recipes/tags/game/">game</a>). </p> <p>Python personnal game code</p> Projectile Motion (Python) 2016-04-08T01:42:01-07:00Tage Burnetthttp://code.activestate.com/recipes/users/4193902/http://code.activestate.com/recipes/580638-projectile-motion/ <p style="color: grey"> Python recipe 580638 by <a href="/recipes/users/4193902/">Tage Burnett</a> (<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This program calculates the characteristics of a projectile in a vacuum at several different locations in our solar system.</p> Sierpinski Gasket (Python) 2016-02-20T10:41:24-08:00Paulo Cavalcantihttp://code.activestate.com/recipes/users/4189949/http://code.activestate.com/recipes/580614-sierpinski-gasket/ <p style="color: grey"> Python recipe 580614 by <a href="/recipes/users/4189949/">Paulo Cavalcanti</a> (<a href="/recipes/tags/fractal/">fractal</a>). </p> <p>Creates a Sierpinski Gasket, by recursively partitioning an initial triangle (a,b,c) into three or four new triangles.</p> Python Mandelbrot Fractal with Tkinter (Python) 2015-05-06T09:57:27-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/579048-python-mandelbrot-fractal-with-tkinter/ <p style="color: grey"> Python recipe 579048 by <a href="/recipes/users/4182514/">Antoni Gual</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 9. </p> <p>Displays in a Tk window a pretty coloured 640x480 Mandelbrot set in 6 seconds. Calculates each one of the 300K pixels with a maximum of 256 iterations. <br> Only Tkinter used. Tested with Python 3.4 <br> I will test any contribution and add it to the code if worthy.</p> simplify webpage (Python) 2015-11-18T14:02:19-08:00Anton Vredegoorhttp://code.activestate.com/recipes/users/2667360/http://code.activestate.com/recipes/579107-simplify-webpage/ <p style="color: grey"> Python recipe 579107 by <a href="/recipes/users/2667360/">Anton Vredegoor</a> (<a href="/recipes/tags/adblocking/">adblocking</a>, <a href="/recipes/tags/drag_and_drop/">drag_and_drop</a>, <a href="/recipes/tags/html2text/">html2text</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/tor/">tor</a>). Revision 4. </p> <p>drag and drop urls from your browser's navigation window to a tkinter widget</p> bookmarks browser for firefox (Python) 2015-07-06T23:15:31-07:00Anton Vredegoorhttp://code.activestate.com/recipes/users/2667360/http://code.activestate.com/recipes/579077-bookmarks-browser-for-firefox/ <p style="color: grey"> Python recipe 579077 by <a href="/recipes/users/2667360/">Anton Vredegoor</a> (<a href="/recipes/tags/bookmarks/">bookmarks</a>, <a href="/recipes/tags/firefox/">firefox</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>a small tkinter gui to browse the .json type bookmark files firefox automatically generates each day. It's meant to be run from a terminal. If a tree item is doubleclicked it prints the uri.</p> Using Tkinter's Invoke Method for testing (Python) 2017-06-13T18:54:02-07:00Stephen Rigdenhttp://code.activestate.com/recipes/users/4191139/http://code.activestate.com/recipes/578978-using-tkinters-invoke-method-for-testing/ <p style="color: grey"> Python recipe 578978 by <a href="/recipes/users/4191139/">Stephen Rigden</a> (<a href="/recipes/tags/invoke/">invoke</a>, <a href="/recipes/tags/mainloop/">mainloop</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/ttk/">ttk</a>, <a href="/recipes/tags/unittest/">unittest</a>, <a href="/recipes/tags/unittests/">unittests</a>). </p> <p>This recipe shows a skeleton unittest fixture that calls a widget's command using <code>invoke</code> without starting tkinter's mainloop. (Tcl8.6.3/Tk8.6.3.)</p> Animated raster graphics demo in Tkinter (Python) 2015-05-05T20:26:41-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/579052-animated-raster-graphics-demo-in-tkinter/ <p style="color: grey"> Python recipe 579052 by <a href="/recipes/users/4182514/">Antoni Gual</a> (<a href="/recipes/tags/animation/">animation</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 4. </p> <p>EDITED: A small animated graphics demo in Tkinter, displaying a 1990's style Rotozoom, more interesting than the TV snow I posted previously. The Tkinter management part is just the same. The code is a little longer as some trig tables must be precalculated for speed. The window size corresponds to the resolution of the old DOS screen 13, as I originally coded the demo for Qbasic. </p> Robust Testing of Tkinter Menu Items with Mocking. (Python) 2017-06-13T18:44:58-07:00Stephen Rigdenhttp://code.activestate.com/recipes/users/4191139/http://code.activestate.com/recipes/578964-robust-testing-of-tkinter-menu-items-with-mocking/ <p style="color: grey"> Python recipe 578964 by <a href="/recipes/users/4191139/">Stephen Rigden</a> (<a href="/recipes/tags/invoke/">invoke</a>, <a href="/recipes/tags/mainloop/">mainloop</a>, <a href="/recipes/tags/mock/">mock</a>, <a href="/recipes/tags/mocking/">mocking</a>, <a href="/recipes/tags/tk/">tk</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/unittest/">unittest</a>, <a href="/recipes/tags/unittesting/">unittesting</a>, <a href="/recipes/tags/unittests/">unittests</a>). Revision 7. </p> <p>This recipe addresses the problems encountered when building robust tests for Tk menus. The software under test is a simple window with two menu items that each invoke a one button dialog box. All user visible text is imported from an external config.ini file. This scenario can lead to fragile test code because of the way TK's invoke(index) command has been implemented. (Tcl8.6.3/Tk8.6.3.)</p> Shortcut Utility (Python) 2015-03-29T20:45:57-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579041-shortcut-utility/ <p style="color: grey"> Python recipe 579041 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/desktop/">desktop</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/ui/">ui</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>I dislike filling my desktop with shortcut icons in Windows. This code enables creating shortcuts in a CSV file.</p> Game of Life - Python 3.4 & tkinter (Python) 2014-09-05T15:02:11-07:00Peter Mhttp://code.activestate.com/recipes/users/4190729/http://code.activestate.com/recipes/578928-game-of-life-python-34-tkinter/ <p style="color: grey"> Python recipe 578928 by <a href="/recipes/users/4190729/">Peter M</a> (<a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>I took this well-know game to design my own solution, and make a GUI for it.</p> <p>To run the program, you will need to create a txt file with rows of dots, so like this:</p> <p>...... ...... ...... ......</p> <p>and name it empty_board.gol (I have tested this program withwith 55x55)</p> <p>It is functional and not object oriented.</p> <p>My game of life algorithm is probably not the best one around (suggestions welcome), but I think this program is a nice demo of with tkinter can do and how easy it is to program GUI's with tkinter.</p> <p>It has been written and tested in python 3.4 but I guess any version 3 should work, and probably only minor changes are needed to make it work in 2.6 or 2.7 (e.g. change tkinter to Tkinter).</p> Analog Clock (Python) 2014-05-14T20:53:39-07:00Paulo Cavalcantihttp://code.activestate.com/recipes/users/4189949/http://code.activestate.com/recipes/578875-analog-clock/ <p style="color: grey"> Python recipe 578875 by <a href="/recipes/users/4189949/">Paulo Cavalcanti</a> (<a href="/recipes/tags/clock/">clock</a>). Revision 3. </p> <p>A python-tkinter analog clock</p> Accordion Widget (Tkinter) (Python) 2014-07-18T11:39:51-07:00Peter Mojeikohttp://code.activestate.com/recipes/users/4190241/http://code.activestate.com/recipes/578911-accordion-widget-tkinter/ <p style="color: grey"> Python recipe 578911 by <a href="/recipes/users/4190241/">Peter Mojeiko</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>An expanding/collapsing widget for Tkinter.</p> <p>usage:</p> <pre class="prettyprint"><code>from accordion import Accordion, Chord root = Tk() accordion = Accordion(root) accordion.pack() chord1 = Chord(accordion, title='Chord') # create widgets and give them chord1 as parent accordion.append_chords([chord1]) root.mainloop() </code></pre> <p>There's a more detailed example at the bottom of the file.</p> Pasting python data into a spread sheet (Python) 2014-09-16T15:49:07-07:00Tomas Nordinhttp://code.activestate.com/recipes/users/4189558/http://code.activestate.com/recipes/578933-pasting-python-data-into-a-spread-sheet/ <p style="color: grey"> Python recipe 578933 by <a href="/recipes/users/4189558/">Tomas Nordin</a> (<a href="/recipes/tags/clipboard/">clipboard</a>, <a href="/recipes/tags/spreadsheet/">spreadsheet</a>). Revision 3. </p> <p>A smooth way to paste data you are working with in python into a spreadsheet. Put into the system clipboard, select a cell and do ctrl-v (at least with ms office and libre-office).</p> All in one Area Calculator (Python) 2014-07-03T09:16:14-07:00karimhttp://code.activestate.com/recipes/users/4190244/http://code.activestate.com/recipes/578901-all-in-one-area-calculator/ <p style="color: grey"> Python recipe 578901 by <a href="/recipes/users/4190244/">karim</a> (<a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/circlearea/">circlearea</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/tranglearea/">tranglearea</a>, <a href="/recipes/tags/trianglearea/">trianglearea</a>). Revision 2. </p> <p>Its a python 3 based All in one Area Calculator.you can calculate Area of Rectangle,Area of Triangle and Area of Circle</p> Setting up a listbox filter in Tkinter(python 2.7) (Python) 2014-04-10T10:25:38-07:00Wyklephhttp://code.activestate.com/recipes/users/4189735/http://code.activestate.com/recipes/578860-setting-up-a-listbox-filter-in-tkinterpython-27/ <p style="color: grey"> Python recipe 578860 by <a href="/recipes/users/4189735/">Wykleph</a> (<a href="/recipes/tags/filter/">filter</a>, <a href="/recipes/tags/listbox/">listbox</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/searchbar/">searchbar</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 3. </p> <p>If you have a listbox and need to filter the contents of the listbox based on the contents of an entry field, this will help you! Shoutout to Nikola-K for the revision. It's much simpler now :D</p>