Latest recipes tagged "options"http://code.activestate.com/recipes/tags/options/new/2012-07-05T02:39:42-07:00ActiveState Code RecipesSetting Namespaces (Python)
2012-07-05T02:39:42-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578195-setting-namespaces/
<p style="color: grey">
Python
recipe 578195
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/helpers/">helpers</a>, <a href="/recipes/tags/library/">library</a>, <a href="/recipes/tags/options/">options</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 2.
</p>
<p>Provides a simple way to deal with program variable versioning.</p>
<p>This module defines two classes to store application settings so that
multiple file versions can coexist with each other. Loading and saving
is designed to preserve all data among the different versions. Errors
are generated to protect the data when type or value violations occur.</p>
Settings Organizer (Python)
2012-07-04T22:16:36-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578173-settings-organizer/
<p style="color: grey">
Python
recipe 578173
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/helpers/">helpers</a>, <a href="/recipes/tags/library/">library</a>, <a href="/recipes/tags/options/">options</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 3.
</p>
<p>Provide an easy method to manage program options among multiple versions.</p>
<p>This module contains two classes used to store application settings in such a
way that multiple file versions can possibly coexist with each other. Loading
and saving settings is designed to preserve as much data between versions. An
error is generated on loading if saving would lead to any data being lost.</p>
Teach the hashbang header new tricks using a dual mode shell/python script (Python)
2011-08-21T07:27:05-07:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/577851-teach-the-hashbang-header-new-tricks-using-a-dual-/
<p style="color: grey">
Python
recipe 577851
by <a href="/recipes/users/2033964/">Oren Tirosh</a>
(<a href="/recipes/tags/hashbang/">hashbang</a>, <a href="/recipes/tags/interpreter/">interpreter</a>, <a href="/recipes/tags/options/">options</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sh/">sh</a>, <a href="/recipes/tags/shell/">shell</a>).
</p>
<p>This dual-mode script is both a Posix shell script and a python script. The shell part looks like a triple-quoted string to the Python interpreter. The shell does not reach anything after the exec statement.</p>
edit dictionary values (possibly restrained) with Tkinter (Python)
2011-03-15T21:37:54-07:00s_h_a_i_ohttp://code.activestate.com/recipes/users/4177334/http://code.activestate.com/recipes/577611-edit-dictionary-values-possibly-restrained-with-tk/
<p style="color: grey">
Python
recipe 577611
by <a href="/recipes/users/4177334/">s_h_a_i_o</a>
(<a href="/recipes/tags/edit/">edit</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/in/">in</a>, <a href="/recipes/tags/options/">options</a>).
</p>
<p>The behaviour of applications sometimes depends on various parameters that can be chosen by the user through some GUI. Quite often, these parameters need take value in a predefined set. Parameters include for instance:</p>
<ul>
<li>The number of replications for a simulator.</li>
<li>Dates of beginning/end of sample for time series access/plot.</li>
<li>Log writing</li>
</ul>
<p>This recipe assumes that</p>
<ul>
<li>Such parameters are stored in a dictionary. Values in the dictionnary are used as initial values for the parameters.</li>
<li>Values are "singleton", i.e non iterable (although they may be strings).</li>
<li>When a value is a list instance, its content represent the set of possible values
The recipe offers a simple way to edit the values in a Tkinter Frame, by adding proper widget to it (constrained value are menubutton while unconstrained values are edit widgets).</li>
</ul>
<p>This is done by the function apply(frame,dict,position), which adds to the Tkinter frame the necessary widgets to edit the dictionary dict. Widgets are placed using grid (hence the frame needs use grid() too) and span on two columns. topleft position (x,y) in grid is specified using position= (x,y,0,0)</p>