| Home | Trees | Indices | Help |
|
|---|
|
|
Classes linking Parameters to Tkinter.
TkParameterized allows flexible graphical representation and manipulation of the parameters of a Parameterized instance or class.
ParametersFrame and ParametersFrameWithApply extend TkParameterized, displaying all the Parameters together in a list. Both allow these Parameters to be edited; ParametersFrame applies changes immediately as they are made, whereas ParametersFrameWithApply makes no changes until a confirmation is given (by pressing the 'Apply' button).
Using these classes to display parameters has several benefits, including that, automatically:
You want to display all parameters of a parameterized instance inside an existing containter (e.g. a window or a frame):
# existing Parameterized instance g from topo import pattern g = pattern.Gaussian()
# existing window t import Tkinter t = Tkinter.Toplevel()
# display all the parameters of g in t from topo.param.tk import ParametersFrame ParametersFrame(t,g) #should be ParametersFrame(t,g).pack(); see ALERT in ParametersFrame
You want a new window displaying only the parameters of your object:
# existing Parameterized instance g from topo import pattern g = pattern.Gaussian()
# display all the parameters of g in a new window from topo.param.tk import edit_parameters edit_parameters(g)
You want to display only some of the parameters of one or more Parameterized instances:
## Existing, non-GUI code from topo import param
- class Object1(param.Parameterized):
- duration = param.Number(2.0,bounds=(0,None),doc='Duration of measurement') displacement = param.Number(0.0,bounds=(-1,1),doc='Displacement from point A')
- class Object2(param.Parameterized):
- active_today = param.Boolean(True,doc='Whether or not to count today') operator_name = param.String('A. Person',doc='Operator today')
o1 = Object1() o2 = Object2()
## Existing window import Tkinter t = Tkinter.Toplevel()
## Flexible GUI representation: display o1.duration, o1.displacement, ## and o2.active_today inside t, ignoring o2.operator_name from topo.param.tk import TkParameterized
t1 = TkParameterized(t,o1) t2 = TkParameterized(t,o2)
t1.pack_param('duration',side='left') t1.pack_param('displacement',side='bottom') t2.pack_param('active_today',side='right')
TkParameterized is itself a subclass of Parameterized, so a TkParameterized class can have its own parameters (in addition to representing those of an external parameterized instance or class).
## Existing class from topo import params
- class X(param.Parameterized):
- one = param.Boolean(True) two = param.Boolean(True)
## Panel to represent an instance of X from Tkinter import Frame from topo.param.tk import TkParameterized
class XPanel(TkParameterized,Frame):
dock = param.Boolean(False,doc='Whether to attach this Panel')
- def __init__(self,master,x):
- self.pack_param('dock',side='top',on_change=self.handle_dock) self.pack_param('one',side='left') self.pack_param('two',side='right')
- def handle_dock(self):
- if self.dock:
- # dock the window
- else:
- # undock the window
## Running the code t = Tkinter.Toplevel() x = X() XPanel(t,x)
$Id: tk.py 9416 2008-10-08 19:36:54Z ceball $
|
|||
|
Button A GUI-specific parameter to display a button. |
|||
|
TkParameterizedBase A Parameterized subclass that maintains Tkinter.Variable shadows (proxies) of its Parameters. |
|||
|
TkParameterized Provide widgets for Parameters of itself and up to one additional Parameterized instance or class. |
|||
|
Translator Abstract class that |
|||
|
DoNothingTranslator Performs no translation. |
|||
| BoolTranslator | |||
|
Eval_ReprTranslator Translates a string to an object by eval()ing the string in __main__.__dict__ (i.e. |
|||
| String_ObjectTranslator | |||
| CSPTranslator | |||
|
ParametersFrame Displays and allows instantaneous editing of the Parameters of a supplied Parameterized. |
|||
|
ParametersFrameWithApply Displays and allows editing of the Parameters of a supplied Parameterized. |
|||
| Balloon | |||
|
Menu Tkinter Menu, but with a way to access entries by name. |
|||
|
TaggedSlider Widget for manipulating a numeric value using either a slider or a text-entry box, keeping the two values in sync. |
|||
|
FocusTakingButton A Tkinter Button that takes the focus when the mouse <Enter>s. |
|||
|
ScrolledFrame XXXX |
|||
| ScrolledWindow | |||
| StatusBar | |||
|
AppWindow A ScrolledWindow with extra features intended to be common to all windows of an application. |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
application_path =
|
|||
output_path =
|
|||
|
|||
Find the path to an existing file, searching in the specified search paths if the filename is not absolute, and converting a UNIX-style path to the current OS's format if necessary. To turn a supplied relative path into an absolute one, the path is appended to each path in (search_paths+the current working directory+the application's base path), in that order, until the file is found. (Similar to Python's os.path.abspath(), except more search paths than just os.getcwd() can be used, and the file must exist.) An IOError is raised if the file is not found anywhere. |
Return the inverse of dictionary dict_. (I.e. return a dictionary with keys that are the values of dict_, and values that are the corresponding keys from dict_.) The values of dict_ must be unique. |
Look for class_ or its superclasses in the keys of dict_; on finding a match, return the value (return None if no match found). Searches from the most immediate class to the most distant (i.e. from class_ to the final superclass of class_). |
Return the keys of d, sorted by value. The values of d must be unique (see inverse) |
|
|
Edit the Parameters of a supplied parameterized instance or class. Specify with_apply=False for a ParametersFrame (which immediately updates the object - no need to press the Apply button). Extra params are passed to the ParametersFrame constructor. |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Oct 12 22:26:29 2008 | http://epydoc.sourceforge.net |