diff -r 1a805cfe9980 Lib/idlelib/ClassBrowser.py --- a/Lib/idlelib/ClassBrowser.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/ClassBrowser.py Tue May 20 14:59:05 2014 +0530 @@ -13,6 +13,8 @@ import os import sys import pyclbr +import tkinter +import re from idlelib import PyShell from idlelib.WindowList import ListedToplevel @@ -21,11 +23,15 @@ class ClassBrowser: - def __init__(self, flist, name, path): + def __init__(self, flist, name, path, _htest=False): # XXX This API should change, if the file doesn't end in ".py" # XXX the code here is bogus! + """ + _htest - bool, change box when location running htest. + """ self.name = name self.file = os.path.join(path[0], self.name + ".py") + self._htest = _htest self.init(flist) def close(self, event=None): @@ -40,6 +46,9 @@ self.top = top = ListedToplevel(flist.root) top.protocol("WM_DELETE_WINDOW", self.close) top.bind("", self.close) + if self._htest: # place dialog below parent if running htest + top.geometry("+%d+%d" % + (flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200)) self.settitle() top.focus_set() # create scrolled canvas @@ -202,7 +211,7 @@ edit = PyShell.flist.open(self.file) edit.gotoline(self.cl.methods[self.name]) -def main(): +def _class_browser(parent): #Wrapper for htest try: file = __file__ except NameError: @@ -213,9 +222,9 @@ file = sys.argv[0] dir, file = os.path.split(file) name = os.path.splitext(file)[0] - ClassBrowser(PyShell.flist, name, [dir]) - if sys.stdin is sys.__stdin__: - mainloop() + flist = PyShell.PyShellFileList(parent) + ClassBrowser(flist, name, [dir], _htest=True) if __name__ == "__main__": - main() + from idlelib.idle_test.htest import run + run(_class_browser) diff -r 1a805cfe9980 Lib/idlelib/PathBrowser.py --- a/Lib/idlelib/PathBrowser.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/PathBrowser.py Tue May 20 14:59:05 2014 +0530 @@ -1,13 +1,21 @@ import os import sys +import tkinter +import re import importlib.machinery from idlelib.TreeWidget import TreeItem from idlelib.ClassBrowser import ClassBrowser, ModuleBrowserTreeItem +from idlelib.PyShell import PyShellFileList + class PathBrowser(ClassBrowser): - def __init__(self, flist): + def __init__(self, flist, _htest=False): + """ + _htest - bool, change box location when running htest + """ + self._htest = _htest self.init(flist) def settitle(self): @@ -87,12 +95,13 @@ sorted.sort() return sorted -def main(): - from idlelib import PyShell - PathBrowser(PyShell.flist) - if sys.stdin is sys.__stdin__: - mainloop() +def _path_browser(parent): + flist = PyShellFileList(parent) + PathBrowser(flist, _htest=True) if __name__ == "__main__": from unittest import main main('idlelib.idle_test.test_pathbrowser', verbosity=2, exit=False) + + from idlelib.idle_test.htest import run + run(_path_browser) diff -r 1a805cfe9980 Lib/idlelib/aboutDialog.py --- a/Lib/idlelib/aboutDialog.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/aboutDialog.py Tue May 20 14:59:05 2014 +0530 @@ -12,11 +12,16 @@ """Modal about dialog for idle """ - def __init__(self, parent, title): + def __init__(self, parent, title, _htest=False): + """ + _htest - bool, change box location when running htest + """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) - self.geometry("+%d+%d" % (parent.winfo_rootx()+30, - parent.winfo_rooty()+30)) + # place dialog below parent if running htest + self.geometry("+%d+%d" % ( + parent.winfo_rootx()+30, + parent.winfo_rooty()+(30 if not _htest else 100))) self.bg = "#707070" self.fg = "#ffffff" self.CreateWidgets() diff -r 1a805cfe9980 Lib/idlelib/configHelpSourceEdit.py --- a/Lib/idlelib/configHelpSourceEdit.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/configHelpSourceEdit.py Tue May 20 14:59:05 2014 +0530 @@ -8,13 +8,14 @@ import tkinter.filedialog as tkFileDialog class GetHelpSourceDialog(Toplevel): - def __init__(self, parent, title, menuItem='', filePath=''): + def __init__(self, parent, title, menuItem='', filePath='', _htest=False): """Get menu entry and url/ local file location for Additional Help User selects a name for the Help resource and provides a web url or a local file as its source. The user can enter a url or browse for the file. + _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) @@ -31,12 +32,14 @@ self.withdraw() #hide while setting geometry #needs to be done here so that the winfo_reqwidth is valid self.update_idletasks() - #centre dialog over parent: - self.geometry("+%d+%d" % - ((parent.winfo_rootx() + ((parent.winfo_width()/2) - -(self.winfo_reqwidth()/2)), - parent.winfo_rooty() + ((parent.winfo_height()/2) - -(self.winfo_reqheight()/2))))) + #centre dialog over parent. below parent if running htest. + self.geometry( + "+%d+%d" % ( + parent.winfo_rootx() + + (parent.winfo_width()/2 - self.winfo_reqwidth()/2), + parent.winfo_rooty() + + ((parent.winfo_height()/2 - self.winfo_reqheight()/2) + if not _htest else 150))) self.deiconify() #geometry set, unhide self.bind('', self.Ok) self.wait_window() @@ -159,11 +162,5 @@ self.destroy() if __name__ == '__main__': - #test the dialog - root = Tk() - def run(): - keySeq = '' - dlg = GetHelpSourceDialog(root, 'Get Help Source') - print(dlg.result) - Button(root,text='Dialog', command=run).pack() - root.mainloop() + from idlelib.idle_test.htest import run + run(GetHelpSourceDialog) diff -r 1a805cfe9980 Lib/idlelib/idle_test/htest.py --- a/Lib/idlelib/idle_test/htest.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/idle_test/htest.py Tue May 20 14:59:05 2014 +0530 @@ -35,10 +35,20 @@ AboutDialog_spec = { 'file': 'aboutDialog', - 'kwds': {'title': 'About test'}, - 'msg': "Try each button" - } + 'kwds': {'title': 'aboutDialog test', + '_htest': True, + }, + 'msg': "Test every button. Ensure Python, TK and IDLE versions " + "are correctly displayed.\n [Close] to exit.", + } +_class_browser_spec = { + 'file': 'ClassBrowser', + 'kwds': {}, + 'msg': "Inspect names of module, class(with superclass if " + "applicable), methods and functions.\nToggle nested items." + "\nN.S: Double click on items does not work", + } _editor_window_spec = { 'file': 'EditorWindow', @@ -54,7 +64,19 @@ '_htest': 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]", + "Close 'Get Name' with a valid entry (printed to Shell), " + "[Cancel], or [X]", + } +GetHelpSourceDialog_spec = { + 'file': 'configHelpSourceEdit', + 'kwds': {'title': 'Get helpsource', + '_htest': True}, + 'msg': "Enter menu item name and help file path\n " + " and more than 30 chars are invalid menu item names.\n" + ", file does not exist are invalid path items.\n" + "Test for incomplete web address for help file path.\n" + "A valid entry will be printed to shell with [0k].\n" + "[Cancel] will print None to shell", } _help_dialog_spec = { @@ -63,6 +85,23 @@ 'msg': "If the help text displays, this works" } +_path_browser_spec = { + 'file': 'PathBrowser', + 'kwds': {}, + 'msg': "Test for correct display of all paths in sys.path." + "\nToggle nested items upto the lowest level." + "\nN.S: Double click on items does not work." + } + +TextViewer_spec = { + 'file': 'textView', + 'kwds': {'title': 'Test textView', + 'text':'The quick brown fox jumps over the lazy dog.\n'*35, + '_htest': True}, + 'msg': "Test for read-only property of text.\n" + "Text is selectable. Window is scrollable.", + } + def run(test): "Display a widget with callable *test* using a _spec dict" root = tk.Tk() diff -r 1a805cfe9980 Lib/idlelib/textView.py --- a/Lib/idlelib/textView.py Mon May 19 22:54:58 2014 -0400 +++ b/Lib/idlelib/textView.py Tue May 20 14:59:05 2014 +0530 @@ -9,15 +9,17 @@ """A simple text viewer dialog for IDLE """ - def __init__(self, parent, title, text, modal=True): + def __init__(self, parent, title, text, modal=True, _htest=False): """Show the given text in a scrollable window with a 'close' button + _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) + # place dialog below parent if running htest self.geometry("=%dx%d+%d+%d" % (625, 500, - parent.winfo_rootx() + 10, - parent.winfo_rooty() + 10)) + parent.winfo_rootx() + 10, + parent.winfo_rooty() + (10 if not _htest else 100))) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' @@ -74,24 +76,6 @@ else: return view_text(parent, title, contents, modal) - if __name__ == '__main__': - #test the dialog - root=Tk() - root.title('textView test') - filename = './textView.py' - with open(filename, 'r') as f: - text = f.read() - btn1 = Button(root, text='view_text', - command=lambda:view_text(root, 'view_text', text)) - btn1.pack(side=LEFT) - btn2 = Button(root, text='view_file', - command=lambda:view_file(root, 'view_file', filename)) - btn2.pack(side=LEFT) - btn3 = Button(root, text='nonmodal view_text', - command=lambda:view_text(root, 'nonmodal view_text', text, - modal=False)) - btn3.pack(side=LEFT) - close = Button(root, text='Close', command=root.destroy) - close.pack(side=RIGHT) - root.mainloop() + from idlelib.idle_test.htest import run + run(TextViewer)