row frame(rowsrow pack(fill=xlabel(rowtext=labelwidth=labelsizepack(side=leftentry entry(rowwidth=entrysizeentry pack(side=rightexpand=yesfill=xself content[labelentry button(boxtext='cancel'command=self oncancelpack(side=rightbutton(boxtext='submit'command=self onsubmitpack(side=rightbox master bind(''(lambda eventself onsubmit())def onsubmit(self)for key in self contentprint(key'\ =>\ 'self content[keyget()override this user inputs in self content[kdef oncancel(self)tk(quit(override if need default is exit class dynamicform(form)def __init__(selflabels=none)labels input('enter field names'split(form __init__(selflabelsdef onsubmit(self)print('field values 'form onsubmit(selfself oncancel(if __name__ ='__main__'import sys if len(sys argv= form(['name''age''job']elsedynamicform(mainloop(precoded fieldsstay after submit input fieldsgo away after submit compare the approach of this module with that of the form row builder function we wrote in ' example - while that example much reduced the amount of code requiredthe module here is noticeably more complete and automatic scheme--it builds the entire form given set of label namesand provides dictionary with every field' entry widget ready to be fetched running this module standalone triggers its self-test code at the bottom without arguments (and when double-clicked in windows file explorer)the self-test generates form with canned input fields captured in figure - and displays the fieldsvalues on enter key presses or submit button clicksc:\pp \internet\socketspython form py age = name =bob job =educatorentertainer with command-line argumentthe form class module' self-test code prompts for an arbitrary set of field names for the formfields can be constructed as dynamically as we simple python file server