>>> from mglutil.gui.InputForm.Tk.gui import InputForm, InputFormDescr
>>> import Tkinter, Pmw
>>> descr = InputFormDescr(title="My First InputForm")
>>> descr.append({'name':'display',
'widgetType':Pmw.RadioSelect,
'listtext':['display','display only', 'undisplay'],
'defaultValue':'display',
'wcfg':{'orient':'horizontal',
'buttontype':'radiobutton'},
'gridcfg':{'sticky': 'we'}})
>>> form = InputForm(
The CallBackFunction class provides support to bind a callback function
with arguments to your widget.
The reference to the function and arguments (including keywords) that are
passed to the CallBackFunction class are stored by its constructor and
then passed on to the function when the callback is activated.
- Example:
Example showing how to use a CallBackFunction object:
>>>from Framework.gui import InputFormDescr, InputForm, CallBackFunction
>>>import Tkinter
>>># 1- define the textvariable option of the Tkinter.Button which is a
>>># Tkinter.StringVar()and set it at GreenButton.
>>>buttonvar = Tkinter.StringVar()
>>>buttonvar.set("Green")
>>># 2- Then Define the callbackfunction you want to call when you click
>>># on the button.
>>>def callback(vars)
... buttonvar = vars[0]
... # This function modifies the value of the buttonvar
... # variable, which has for consequence the modification of the
... # text in the button.
...
... if buttonvar.get()=="Green":
... buttonvar.set("Yellow")
... elif buttonvar.get()=="Yellow":
... buttonvar.set("Green")
>>># 3- Then define your Button using InputFormDescr.
>>>idf = InputFormDescr(title ="Button")
>>>idf.append({'widgetType':Tkinter.Button,
... 'wcfg':{'width':10,'height':2,
... 'textvariable':buttonvar,
... 'command':CallBackFunction(callback,(buttonvar,))},
... 'gridcfg':{}})
>>
>>>form = InputForm(idf, modal=0, blocking=0)
>>>form.go()