| |
- nvEntryField
- nvGenericGui
class nvEntryField |
|
Simple entry field class with label. |
|
Methods defined here:
- __init__(self, parent, variable, label='', labelpos='n', validate={})
- Constructor.
Input:
parent: a Tk window object (e.g. Tk())
variable: a Tkint
er.StringVar, typically. This variable will be updated upon the user typing <Return>.
label: label will be positioned on the north side by default.
- callback(self, *args)
- Invoked when pressing <Return>
- config(self, **kw)
- Mimics Tk's config method
- configure(self, **kw)
- setvalue(self, val)
- Mimics Pmw's setvalue method
- winfo_class(self, *args)
|
class nvGenericGui |
|
Generic Gui Component Assembler. This class automates the process of building Guis,
leaving the user the task to assemble slider/entry box and switch widgets by
specifying a grid layout. The type of widgets will be chosen according to the
property specifications dict passed to the constructor. |
|
Methods defined here:
- AddLoadButton(self)
- Add load property button
- AddResetButton(self)
- Add reset property button
- AddSaveButton(self)
- Add save property button
- BindDestructor(self, callback_function)
- Bind window destructor to callback_function. The function
callback_function will be invoked when the user destroys the
window. It can be be used to clean up resources.
The signature of the call_back_function should be
def callback_function(*arg)
- BindEvents(self, callback_function)
- Bind events to user supplied callback_function, the latter should have
the signature
def callback_function(name, *args):
# do stuff when name is updated
where name is a key to the properties dict passed to the constructor
and *args are event parameters
- Configure(self, **cfg)
- Apply Tkinter config options
- Disable(self, name='')
- Disable widget 'name'
- Enable(self, name='')
- Enable widget 'name'
- Get(self, name=None)
- Return value pointed by widget
Usage:
Get('Option name') return given option
or
Get() returns all options as a dict
- GetDefaults(self)
- Return dict of default options
- Load(self, *args)
- Load settings from file
- Print(self)
- Reset(self, *args)
- Reset all properties to default values.
- Save(self, *args)
- Save settings in file
- Set(self, name_val, val=None)
- Adjust widget to match val
Usage:
Set('name_val', val) sets option 'name_val'
or
Set({'Option 1':val1,...}) sets all options
- SetDefaults(self, name_val)
- Change default values.
name_val: {name: val,...}
- Show(self, **options)
- Show the Gui layout.
options: acceptable Tkinter grid() options
- __init__(self, root=None, properties={}, layout=(), reset=True, save_load=True)
- Constructor.
root: a Tkinter object (e.g. Tk())
properties: a dictionary {name: [default_value, (min, max), n_values, description], ...}
name: The widget will be referred to by 'name', which will also serve as label.
default_value: initial value, the type of which will help determine the kind of widget:
- A string value will create an entry box, or a scrollable list box if the
second argument is a list.
- A number will create either a slider if n_values>1 or a switch
if n_values==1.
if the second field is a function or a method, then a button will be created. This
field can also be used to create a choice for the scrollable list box. In case of
a slider, the second field should provide a tuple of min/max values.
description: a string used for 'balloons'
A function or method in the 3rd field will create a Pmw Counter.
layout: a nested tuple specifying the grid positioning (row/column) of the widgets.
The elements of the nested list should be the keys of the property dict defined
above (i.e. 'name').
Examples:
scrollable list box showing 2 elements ['a', ['a','b','c'], 2, 'My list', 'nw']
| |