diff -r d7950e916f20 Lib/idlelib/configSectionNameDialog.py --- a/Lib/idlelib/configSectionNameDialog.py Thu Mar 13 20:54:30 2014 -0400 +++ b/Lib/idlelib/configSectionNameDialog.py Thu Mar 13 23:20:31 2014 -0400 @@ -8,7 +8,7 @@ import tkinter.messagebox as tkMessageBox class GetCfgSectionNameDialog(Toplevel): - def __init__(self, parent, title, message, used_names): + def __init__(self, parent, title, message, used_names, testing=False): """ message - string, informational message to display used_names - string collection, names already in use for validity check @@ -33,7 +33,8 @@ parent.winfo_rootx() + (parent.winfo_width()/2 - self.winfo_reqwidth()/2), parent.winfo_rooty() + - (parent.winfo_height()/2 - self.winfo_reqheight()/2) + ((parent.winfo_height()/2 - self.winfo_reqheight()/2) + if not testing else 100) ) ) #centre dialog over parent self.deiconify() #geometry set, unhide self.wait_window() @@ -92,15 +93,5 @@ import unittest unittest.main('idlelib.idle_test.test_config_name', verbosity=2, exit=False) - # also human test the dialog - root = Tk() - def run(): - dlg=GetCfgSectionNameDialog(root,'Get Name', - "After the text entered with [Ok] is stripped, , " - "'abc', or more that 30 chars are errors. " - "Close with a valid entry (printed), [Cancel], or [X]", - {'abc'}) - print(dlg.result) - Message(root, text='').pack() # will be needed for oher dialog tests - Button(root, text='Click to begin dialog test', command=run).pack() - root.mainloop() + from idlelib.idle_test.htest import run + run(GetCfgSectionNameDialog) diff -r d7950e916f20 Lib/idlelib/idle_test/htest.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/idlelib/idle_test/htest.py Thu Mar 13 23:20:31 2014 -0400 @@ -0,0 +1,27 @@ +import tkinter as tk + +GetCfgSectionNameDialog_spec = { + 'kwds': {'title':'Get Name', + 'message':'Enter something', + 'used_names': {'abc'}, + 'testing': True}, + 'msg': "After the text entered with [Ok] is stripped, , " + "'abc', or more that 30 chars are errors.\n" + "Close 'Get Name' with a valid entry (printed to Shell), [Cancel], or [X]", + } + +def run(klas): + root = tk.Tk() + klas_spec = globals()[klas.__name__+'_spec'] + klas_kwds = klas_spec['kwds'] + klas_kwds['parent'] = root # does Idle use 'parent' consistently? + # print(klas, klas_spec) + def run_klas(): + widget = klas(**klas_kwds) + try: + print(widget.result) + except AttributeError: + pass + tk.Label(root, text=klas_spec['msg'], justify='left').pack() + tk.Button(root, text='Test ' + klas.__name__, command=run_klas).pack() + root.mainloop()