Popular recipes tagged "meta:loc=140"http://code.activestate.com/recipes/tags/meta:loc=140/2017-05-16T18:18:31-07:00ActiveState Code RecipesMousewheel binding to scrolling area Tkinter (multiplatform) (Python) 2017-05-16T18:18:31-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/578894-mousewheel-binding-to-scrolling-area-tkinter-multi/ <p style="color: grey"> Python recipe 578894 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/mousewheel/">mousewheel</a>, <a href="/recipes/tags/scrollbar/">scrollbar</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 28. </p> <p>The behaviour of the mouse wheel is similar to the one on Windows.</p> <p>I tested this program on Windows 7 and on Linux Mint 17. Please let me know if this code doesn't work on your platform. I will appreciate any comments.</p> <p>This is a practical application of this recipe: a scrolling frame with mouse wheel support.</p> <p><a href="https://code.activestate.com/recipes/580640-scrolling-frame-with-mouse-wheel-support" rel="nofollow">https://code.activestate.com/recipes/580640-scrolling-frame-with-mouse-wheel-support</a></p> Simultaneous panels (Tkinter). Moving several panels at the same time in panedwindow widgets. (Python) 2017-01-15T15:02:09-08:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/578873-simultaneous-panels-tkinter-moving-several-panels-/ <p style="color: grey"> Python recipe 578873 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/draggable/">draggable</a>, <a href="/recipes/tags/pannedwindow/">pannedwindow</a>, <a href="/recipes/tags/syncronous/">syncronous</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 14. </p> <p>Several paned windows which you can drag their shash at the same time. They are grouped by tags.</p> Tkinter simultaneous scrolling (Python) 2016-11-20T00:29:52-08:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/578874-tkinter-simultaneous-scrolling/ <p style="color: grey"> Python recipe 578874 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/multiplatform/">multiplatform</a>, <a href="/recipes/tags/scroll/">scroll</a>, <a href="/recipes/tags/scrollbar/">scrollbar</a>, <a href="/recipes/tags/simultaneous/">simultaneous</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 7. </p> <p>Scroll several scrollbars at the same time.</p> processing (Python) 2012-01-09T02:23:35-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578004-processing/ <p style="color: grey"> Python recipe 578004 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/framework/">framework</a>, <a href="/recipes/tags/gui/">gui</a>). </p> <p>This module was inspired by <a href="http://processing.org/" rel="nofollow">http://processing.org/</a> . The code is meant to mimic an extremely small subset of this high-performance library. After seeing how easy it was to accomplish certain task in the Java framework, a desire was created to have a simple starting point to create little graphical experiments that would be easy to program without haveing to know a lot of details regarding setup, timing, et cetera. This is the result of that desire.</p> Smarter Default Arguments (Python) 2011-08-12T23:06:57-07:00Eric Snowhttp://code.activestate.com/recipes/users/4177816/http://code.activestate.com/recipes/577786-smarter-default-arguments/ <p style="color: grey"> Python recipe 577786 by <a href="/recipes/users/4177816/">Eric Snow</a> (<a href="/recipes/tags/default_arguments/">default_arguments</a>, <a href="/recipes/tags/deferred/">deferred</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/functions/">functions</a>). Revision 3. </p> <p>Improved handling of mutable and deferred default arguments. After the recipe you'll find an explanation of what that means.</p> <p>Works for 2.7 with minor tweaks (getfullargspec --> getargspec).</p> Simple graph algorithms with a modular design (Python) 2011-04-21T13:40:32-07:00jimmy2timeshttp://code.activestate.com/recipes/users/4177690/http://code.activestate.com/recipes/577668-simple-graph-algorithms-with-a-modular-design/ <p style="color: grey"> Python recipe 577668 by <a href="/recipes/users/4177690/">jimmy2times</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/breadth/">breadth</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/directed/">directed</a>, <a href="/recipes/tags/first/">first</a>, <a href="/recipes/tags/graph/">graph</a>, <a href="/recipes/tags/object/">object</a>, <a href="/recipes/tags/oriented/">oriented</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/theory/">theory</a>, <a href="/recipes/tags/undirected/">undirected</a>, <a href="/recipes/tags/visit/">visit</a>). Revision 7. </p> <p>The purpose of this recipe is to look at algorithmic graph theory from an object-oriented perspective.</p> <p>A graph is built on top of a dictionary indexed by its vertices, each item being the set of neighbours of the key vertex. This ensures that iterating through the neighbours of a vertex is still efficient in sparse graphs (as with adjacency lists) while at the same time checking for adjacency is expected constant-time (as with the adjacency matrix).</p> <p>Any valid class of graph must implement the interface defined by AbstractGraph.</p> <p>A generic search algorithm takes as input a graph, source and target vertices and a queue. A queue must implement the methods Q.get(), Q.put() and Q.empty() in such a way to get the desired order in visiting the vertices.</p> <p>Given this pattern, breadth-first and depth-first search are essentially defined by the corresponding expansion policies: the first one uses an actual FIFO queue, the second one a LIFO queue (or stack).</p> Dynamical Billiards Simulation Map (Python) 2010-11-07T18:21:06-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577455-dynamical-billiards-simulation-map/ <p style="color: grey"> Python recipe 577455 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/chaos/">chaos</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 4. </p> <p>It creates fractal-like map plots from the simulation.</p> <p>(See my other post titled "Dynamical Billiards Simulation" first!)</p> <p>I had to keep image size and maxSteps small otherwise the calculation takes too long!</p> <p>(It shows what percentage of calculations completed every 10 seconds also.)</p> Copy files over SSH using paramiko (Python) 2015-12-06T14:19:15-08:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/ <p style="color: grey"> Python recipe 576810 by <a href="/recipes/users/4170754/">ccpizza</a> (<a href="/recipes/tags/paramiko/">paramiko</a>, <a href="/recipes/tags/scp/">scp</a>, <a href="/recipes/tags/ssh/">ssh</a>). Revision 20. </p> <p>This script copies files in unattended mode over SSH using a glob pattern. It uses the <a href="http://www.lag.net/paramiko/">paramiko</a> module behind the scenes. It operates as an actual SSH client, and does <em>not</em> rely on any command line utilities, such as <code>scp</code>.</p> <p>It first tries to connect using a key from a private key file or from an SSH agent. If RSA authentication fails, it will try to authenticate with a password if passwords are allowed on the SSH server. Assumes the <code>rsa_private_key</code> was generated with an empty passphrase.</p> <p>On most linux/unix-like systems paramiko can be installed with <code>sudo easy_install paramiko</code> or <code>pip install paramiko</code> or using the built-in system package manager.</p> <p>See also <a href="http://www.paramiko.org/installing.html" rel="nofollow">http://www.paramiko.org/installing.html</a></p> Morphing Plasma Fractal Applet (Java) 2010-03-26T04:58:36-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577147-morphing-plasma-fractal-applet/ <p style="color: grey"> Java recipe 577147 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/applet/">applet</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>). </p> <p>It displays a continuously changing plasma fractal.</p> Context manager for restoring a value (Python) 2010-01-09T07:14:06-08:00George Sakkishttp://code.activestate.com/recipes/users/2591466/http://code.activestate.com/recipes/576977-context-manager-for-restoring-a-value/ <p style="color: grey"> Python recipe 576977 by <a href="/recipes/users/2591466/">George Sakkis</a> (<a href="/recipes/tags/contextlib/">contextlib</a>, <a href="/recipes/tags/context_manager/">context_manager</a>). Revision 8. </p> <p>Often one wants to rebind a name or modify a mutable object, perform a bunch of actions and finally restore the name/object to its original state. An example is redirecting stdout/stderr temporarily (<a href="http://www.diveintopython.org/scripts_and_streams/stdin_stdout_stderr.html" rel="nofollow">http://www.diveintopython.org/scripts_and_streams/stdin_stdout_stderr.html</a>). The <em>restoring</em> context manager shown below simplifies this pattern::</p> <pre class="prettyprint"><code>import sys # prints in console print "hello world!" with restoring('sys.stdout'): with open('hello.txt', 'w') as sys.stdout: # prints in file print "hello world!" # prints in console again print "hello world!" </code></pre> Bouncy Balls (Python) 2007-02-23T17:25:11-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/502254-bouncy-balls/ <p style="color: grey"> Python recipe 502254 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>This recipe is designed to show sample usage of the physics module. Once the program is running, the window can be dragged around the screen; and the balls will react accordingly. If an error is displayed on the screen, the window moved to show the rest of the error message.</p> Finding (and Replacing) Nemo (Python) 2006-06-06T16:50:12-07:00Aristide Grangehttp://code.activestate.com/recipes/users/2909413/http://code.activestate.com/recipes/496783-finding-and-replacing-nemo/ <p style="color: grey"> Python recipe 496783 by <a href="/recipes/users/2909413/">Aristide Grange</a> (<a href="/recipes/tags/text/">text</a>). Revision 2. </p> <p>Instant regular expressions. On each keystroke, all matches of the given text are highlighted, and the corresponding replacements are performed. Parts of the regular expression can be selected to make their scope appear in the original text.</p> File Unzip (Python) 2005-04-29T05:29:48-07:00Doug Toltonhttp://code.activestate.com/recipes/users/468468/http://code.activestate.com/recipes/252508-file-unzip/ <p style="color: grey"> Python recipe 252508 by <a href="/recipes/users/468468/">Doug Tolton</a> (<a href="/recipes/tags/files/">files</a>). Revision 2. </p> <p>A Python class to extract zip files. It's also written for easy use as a standalone script from the commandline.</p> include function name and line number automatically in debug statements (Python) 2002-08-14T15:06:48-07:00Christian Birdhttp://code.activestate.com/recipes/users/627471/http://code.activestate.com/recipes/144838-include-function-name-and-line-number-automaticall/ <p style="color: grey"> Python recipe 144838 by <a href="/recipes/users/627471/">Christian Bird</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>This recipe allows a user to place debug messages, error messages and standard messages throughout a program. The function name and line number will be added to each debug and error message before it is printed out. In addition, each of these messages can be passed to multiple handler objects that can direct the output to log files, e-mails, stdout, etc.</p>