Most viewed recipes tagged "edit"http://code.activestate.com/recipes/tags/edit/views/2011-03-15T21:37:54-07:00ActiveState Code Recipesedit 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>