Popular recipes tagged "meta:loc=130"http://code.activestate.com/recipes/tags/meta:loc=130/2017-03-11T03:43:56-08:00ActiveState Code RecipesTkinter frame with gradient (Python) 2017-03-11T03:43:56-08:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580761-tkinter-frame-with-gradient/ <p style="color: grey"> Python recipe 580761 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/frame/">frame</a>, <a href="/recipes/tags/gradient/">gradient</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 4. </p> <p>Frame with linear gradient using PIL. </p> <p>It's also possible to make the same trick using tkinter PhotoImage.</p> <p><a href="http://stackoverflow.com/questions/10417524/why-is-photoimage-put-slow" rel="nofollow">http://stackoverflow.com/questions/10417524/why-is-photoimage-put-slow</a></p> <p>But PIL is more efficient:</p> <p><a href="https://groups.google.com/forum/#%21topic/comp.lang.python/nQ6YO-dTz10" rel="nofollow">https://groups.google.com/forum/#!topic/comp.lang.python/nQ6YO-dTz10</a></p> <p>Possible values for <strong>orient</strong> are: <em>VERTICAL</em>, <em>HORIZONTAL</em>. If <strong>orient</strong> is "vertical", then width is mandatory. If <strong>orient</strong> is "horizontal", then height is mandatory. If <strong>steps</strong> is <em>None</em>, then the gradient is composed of adjacent lines.</p> <p>One possible practical application of gradient frames are tool bars. Gradient guives a visual clue of when an area starts and when an area finish. </p> Use Gtk.TreeView to browse MySql databases (Python) 2013-11-27T14:06:20-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578775-use-gtktreeview-to-browse-mysql-databases/ <p style="color: grey"> Python recipe 578775 by <a href="/recipes/users/4188571/">Anonimista</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/mysqldb/">mysqldb</a>, <a href="/recipes/tags/user_interface/">user_interface</a>). </p> <p>Use Gtk.TreeView to browse MySql database structure from database to tables and views and to columns</p> Takuzu solver (Python) 2013-01-12T05:26:55-08:00Eviatar Bachhttp://code.activestate.com/recipes/users/4184885/http://code.activestate.com/recipes/578414-takuzu-solver/ <p style="color: grey"> Python recipe 578414 by <a href="/recipes/users/4184885/">Eviatar Bach</a> (<a href="/recipes/tags/constraint/">constraint</a>, <a href="/recipes/tags/constraint_solver/">constraint_solver</a>, <a href="/recipes/tags/puzzle/">puzzle</a>, <a href="/recipes/tags/takuzu/">takuzu</a>). Revision 2. </p> <p>A Takuzu solver implemented using Google's Constraint Programming solver, part of the or-tools project.</p> <p>A Takuzu board consists of a square grid of binary cells. There must be an equal number of 0s and 1s in every row and column, no duplicate rows or columns, and no more than two of the same bit consecutive in every row and column.</p> Seven Bit Colored Analogue Bar Graph Generator DEMO... (Python) 2011-03-17T22:14:52-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577612-seven-bit-colored-analogue-bar-graph-generator-dem/ <p style="color: grey"> Python recipe 577612 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/analogue/">analogue</a>, <a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/bargraph/">bargraph</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>). Revision 3. </p> <p>..For STANDARD Python 2.6 and above...</p> <p>This code will display a horizontal full colour analogue "VU" style meter. It displays green for normal, yellow for warning and red for danger with a critical error beep near the end of full scale, at value 120+.</p> <p>This version is for Python 2.6 and above and only for the Linux, (*nix?), platform.</p> <p>It is an "at a glance" display that is in colour rather than having to read say a digitally generated number.</p> <p>A Python 3.x version can be found here:-</p> <p><a href="http://www.linuxformat.com/forums/viewtopic.php?t=13443" rel="nofollow">http://www.linuxformat.com/forums/viewtopic.php?t=13443</a></p> <p>This has uses "for at a glance" voltmeters, ammeters, data-loggers, anemometers etc, etc...</p> <p>Watch for wordwrapping etc...</p> <p>NOTE:- This is Public Domain and you may do with it as you please.</p> <p>73...</p> <p>Bazza, G0LCU...</p> <p>Team AMIGA...</p> Virtual collections (Python) 2010-03-09T03:43:13-08:00Chris Leonghttp://code.activestate.com/recipes/users/4173277/http://code.activestate.com/recipes/577092-virtual-collections/ <p style="color: grey"> Python recipe 577092 by <a href="/recipes/users/4173277/">Chris Leong</a> (<a href="/recipes/tags/collections/">collections</a>). </p> <p>This recipe creates a collection proxy which allows several lists to be treated as one. When the collection proxy is accessed/modified, it is as though the operation was performed one the underlying lists.</p> Code_Fouad_Teniou (Python) 2011-08-04T12:03:41-07:00Fouad Teniouhttp://code.activestate.com/recipes/users/4155345/http://code.activestate.com/recipes/576995-code_fouad_teniou/ <p style="color: grey"> Python recipe 576995 by <a href="/recipes/users/4155345/">Fouad Teniou</a> (<a href="/recipes/tags/algorithm/">algorithm</a>). Revision 3. </p> <p>Code_Fouad_Teniou program allows you to encrypt and decrypt text by using a key ( made_key). However, the key is a set of numbers selected at random and the program allows you to create an infinity numbers of this key, which make the code impossible to crack. Though, I used a metaclass to access the methods used in my program to allow permutation of such methods in a way to perform desirable tasks and in a specific order to suit the need of the programmer’s outcome. </p> Run a function in a separate (forked) process without blocking (Python) 2008-02-28T22:22:18-08:00Gary Eakinshttp://code.activestate.com/recipes/users/470921/http://code.activestate.com/recipes/550801-run-a-function-in-a-separate-forked-process-withou/ <p style="color: grey"> Python recipe 550801 by <a href="/recipes/users/470921/">Gary Eakins</a> (<a href="/recipes/tags/fork/">fork</a>, <a href="/recipes/tags/mmap/">mmap</a>, <a href="/recipes/tags/process/">process</a>). Revision 2. </p> <p>A procedure that runs a function asynchronously in a forked process (Availability: Macintosh, Unix). The return from the specified function is written into an anonymous memory map (mmap: requires +Python 2.5). This can be useful for releasing resources used by the function such as memory, updating a gui or cli widget, or other weirdness.</p> Quickslice decorator: Abbreviated slice arguments in functions (Python) 2005-05-31T19:30:02-07:00Brian Beckhttp://code.activestate.com/recipes/users/2425329/http://code.activestate.com/recipes/415500-quickslice-decorator-abbreviated-slice-arguments-i/ <p style="color: grey"> Python recipe 415500 by <a href="/recipes/users/2425329/">Brian Beck</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 4. </p> <p>Sometimes I wish slice creation had a form that looked more like its invocation: [1:5], for example. This recipe allows slice arguments to be passed that look like {1:5}. NOTE: I don't recommend actually using this in practice. It will most likely just confuse any readers of your code. It is just a proof-of-concept. In an interview with Guido van Rossum, Guido was explaining the benefits of Python's built-in types. He gave an example of being able to pass slices as arguments instead of having individual start, stop and step arguments -- and this is very true. But I don't think a syntax to concisely create slices should be out of the question. (Step is not supported by this syntax, it wouldn't be possible and I rarely find myself using step anyway).</p> safer serialization of simple python types (Python) 2005-06-02T08:35:45-07:00S Whttp://code.activestate.com/recipes/users/1759688/http://code.activestate.com/recipes/415503-safer-serialization-of-simple-python-types/ <p style="color: grey"> Python recipe 415503 by <a href="/recipes/users/1759688/">S W</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 7. </p> <p>Unpickling from an untrusted source, such as a network connection, can allow maliciously formed pickles to run arbitrary code.</p> <p>This recipe presents a simple solution for serializing and unserializing simple Python types. Only simple Python types can be serialized, which makes the use of this algorithm safer than using the pickle module.</p> <p>NB: I've changes this recipe drastically. It used to use a rather slow string slicing technique, which was a very bad example of how to use strings in Python! The cStringIO provided a faster, simpler replacement. This recipe now serializes faster than the Pickle module (not cPickle).</p> <p>NB: A Python 2.4 version of this recipe is available here: <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415791" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415791</a></p> Yet another Set class for Python (Python) 2002-01-13T01:16:56-08:00Gonçalo Rodrigueshttp://code.activestate.com/recipes/users/140909/http://code.activestate.com/recipes/106469-yet-another-set-class-for-python/ <p style="color: grey"> Python recipe 106469 by <a href="/recipes/users/140909/">Gonçalo Rodrigues</a> (<a href="/recipes/tags/oop/">oop</a>). Revision 8. </p> <p>This is a pure Pythonic implementation of a set class. The syntax and methods implemented are, for the most part, borrowed from PEP 218 by Greg Wilson.</p> <p>Python version: 2.2</p>