cpython: 038cbbef4539 (original) (raw)
Mercurial > cpython
changeset 90818:038cbbef4539 3.4
Issue #21477: Idle htest: merge and modify run and runall; add many tests. Patch by Saimadhav Heblikar [#21477]
line wrap: on
line diff
--- a/Lib/idlelib/CallTipWindow.py +++ b/Lib/idlelib/CallTipWindow.py @@ -133,37 +133,36 @@ class CallTip: return bool(self.tipwindow) +def _calltip_window(parent):
- root = Tk()
- root.title("Test calltips")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
-############################### -# -# Test Code -# -class container: # Conceptually an editor_window
- def init(self):
root = Tk()[](#l1.19)
text = self.text = Text(root)[](#l1.20)
text.pack(side=LEFT, fill=BOTH, expand=1)[](#l1.21)
text.insert("insert", "string.split")[](#l1.22)
root.update()[](#l1.23)
self.calltip = CallTip(text)[](#l1.24)
- class MyEditWin: # comparenceptually an editor_window
def __init__(self):[](#l1.26)
text = self.text = Text(root)[](#l1.27)
text.pack(side=LEFT, fill=BOTH, expand=1)[](#l1.28)
text.insert("insert", "string.split")[](#l1.29)
root.update()[](#l1.30)
self.calltip = CallTip(text)[](#l1.31)
text.event_add("<<calltip-show>>", "(")[](#l1.33)
text.event_add("<<calltip-hide>>", ")")[](#l1.34)
text.bind("<<calltip-show>>", self.calltip_show)[](#l1.35)
text.bind("<<calltip-hide>>", self.calltip_hide)[](#l1.36)
text.event_add("<<calltip-show>>", "(")[](#l1.37)
text.event_add("<<calltip-hide>>", ")")[](#l1.38)
text.bind("<<calltip-show>>", self.calltip_show)[](#l1.39)
text.bind("<<calltip-hide>>", self.calltip_hide)[](#l1.40)
text.focus_set()[](#l1.42)
root.mainloop()[](#l1.43)
text.focus_set()[](#l1.44)
root.mainloop()[](#l1.45)
def calltip_show(self, event):[](#l1.49)
self.calltip.showtip("Hello world", "insert", "end")[](#l1.50)
def calltip_hide(self, event):[](#l1.54)
self.calltip.hidetip()[](#l1.55)
--- a/Lib/idlelib/ClassBrowser.py +++ b/Lib/idlelib/ClassBrowser.py @@ -13,6 +13,7 @@ XXX TO DO: import os import sys import pyclbr +import re from idlelib import PyShell from idlelib.WindowList import ListedToplevel @@ -21,11 +22,15 @@ from idlelib.configHandler import idleCo class ClassBrowser:
- 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
"""[](#l2.19)
_htest - bool, change box when location running htest.[](#l2.20)
"""[](#l2.21) self.name = name[](#l2.22) self.file = os.path.join(path[0], self.name + ".py")[](#l2.23)
self._htest = _htest[](#l2.24) self.init(flist)[](#l2.25)
def close(self, event=None): @@ -40,6 +45,9 @@ class ClassBrowser: 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[](#l2.32)
top.geometry("+%d+%d" %[](#l2.33)
(flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200))[](#l2.34) self.settitle()[](#l2.35) top.focus_set()[](#l2.36) # create scrolled canvas[](#l2.37)
@@ -202,7 +210,7 @@ class MethodBrowserTreeItem(TreeItem): 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 +221,9 @@ def main(): file = sys.argv[0] dir, file = os.path.split(file) name = os.path.splitext(file)[0]
--- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/ColorDelegator.py @@ -253,17 +253,23 @@ class ColorDelegator(Delegator): for tag in self.tagdefs: self.tag_remove(tag, "1.0", "end") -def main(): +def _color_delegator(parent): from idlelib.Percolator import Percolator root = Tk()
- root.title("Test ColorDelegator")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- with open(file, 'r') as f:
source = f.read()[](#l3.17)
- text = Text(root, background="white")
insert only a sample portion
- text.insert("insert", source[:690]) text.pack(expand=1, fill="both")
- text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d) root.mainloop() if name == "main":
- main()
--- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -525,16 +525,17 @@ class IOBinding: if self.editwin.flist: self.editwin.update_recent_files_list(filename) -def test(): +def _io_binding(parent): root = Tk()
- root.title("Test IOBinding")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150)) class MyEditWin: def init(self, text): self.text = text self.flist = None self.text.bind("", self.open) self.text.bind("", self.save)
self.text.bind("<Alt-s>", self.save_as)[](#l4.19)
self.text.bind("<Alt-z>", self.save_a_copy)[](#l4.20) def get_saved(self): return 0[](#l4.21) def set_saved(self, flag): pass[](#l4.22) def reset_undo(self): pass[](#l4.23)
@@ -542,16 +543,13 @@ def test(): self.text.event_generate("<>") def save(self, event): self.text.event_generate("<>")
def save_as(self, event):[](#l4.28)
self.text.event_generate("<<save-window-as-file>>")[](#l4.29)
def save_a_copy(self, event):[](#l4.30)
self.text.event_generate("<<save-copy-of-window-as-file>>")[](#l4.31)
+ text = Text(root) text.pack() text.focus_set() editwin = MyEditWin(text) io = IOBinding(editwin)
--- a/Lib/idlelib/MultiCall.py +++ b/Lib/idlelib/MultiCall.py @@ -420,9 +420,12 @@ def MultiCallCreator(widget): _multicall_dict[widget] = MultiCall return MultiCall -if name == "main":
+ +def _multi_call(parent): root = tkinter.Tk()
- root.title("Test MultiCall")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150)) text = MultiCallCreator(tkinter.Text)(root) text.pack() def bindseq(seq, n=[0]): @@ -438,8 +441,13 @@ if name == "main": bindseq("") bindseq("") bindseq("")
- bindseq("") bindseq("") bindseq("") bindseq("") bindseq("") root.mainloop() + +if name == "main":
- from idlelib.idle_test.htest import run
- run(_multi_call)
--- a/Lib/idlelib/MultiStatusBar.py +++ b/Lib/idlelib/MultiStatusBar.py @@ -17,16 +17,29 @@ class MultiStatusBar(Frame): label = self.labels[name] label.config(text=text) -def _test():
- b = Frame()
- c = Text(b)
- c.pack(side=TOP)
- a = MultiStatusBar(b)
- a.set_label("one", "hello")
- a.set_label("two", "world")
- a.pack(side=BOTTOM, fill=X)
- b.pack()
- b.mainloop()
+def _multistatus_bar(parent):
- root = Tk()
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d" %(x, y + 150))
- root.title("Test multistatus bar")
- frame = Frame(root)
- text = Text(frame)
- text.pack()
- msb = MultiStatusBar(frame)
- msb.set_label("one", "hello")
- msb.set_label("two", "world")
- msb.pack(side=BOTTOM, fill=X)
- button = Button(root, text="Update status", command=change)
- button.pack(side=BOTTOM)
- frame.pack()
- frame.mainloop()
- root.mainloop()
--- a/Lib/idlelib/ObjectBrowser.py +++ b/Lib/idlelib/ObjectBrowser.py @@ -9,6 +9,8 @@
XXX TO DO:
- for classes/modules, add "open source" to object browser
+import re + from idlelib.TreeWidget import TreeItem, TreeNode, ScrolledCanvas from reprlib import Repr @@ -119,12 +121,13 @@ def make_objecttreeitem(labeltext, objec c = ObjectTreeItem return c(labeltext, object, setfunction) -# Test script -def _test(): +def _object_browser(parent): import sys from tkinter import Tk root = Tk()
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 100)) root.configure(bd=0, bg="yellow") root.focus_set() sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1) @@ -135,4 +138,5 @@ def _test(): root.mainloop() if name == 'main':
--- a/Lib/idlelib/PathBrowser.py +++ b/Lib/idlelib/PathBrowser.py @@ -1,13 +1,20 @@ import os import sys +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, _htest=False):
"""[](#l8.18)
_htest - bool, change box location when running htest[](#l8.19)
"""[](#l8.20)
self._htest = _htest[](#l8.21) self.init(flist)[](#l8.22)
def settitle(self): @@ -87,12 +94,13 @@ class DirBrowserTreeItem(TreeItem): sorted.sort() return sorted -def main():
- from idlelib import PyShell
- PathBrowser(PyShell.flist)
- if sys.stdin is sys.stdin:
mainloop()[](#l8.33)
if name == "main": from unittest import main main('idlelib.idle_test.test_pathbrowser', verbosity=2, exit=False) +
--- a/Lib/idlelib/ScrolledList.py +++ b/Lib/idlelib/ScrolledList.py @@ -119,21 +119,22 @@ class ScrolledList: pass -def test(): +def _scrolled_list(parent): root = Tk()
- root.title("Test ScrolledList")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150)) class MyScrolledList(ScrolledList):
def fill_menu(self): self.menu.add_command(label="pass")[](#l9.15)
def fill_menu(self): self.menu.add_command(label="right click")[](#l9.16) def on_select(self, index): print("select", self.get(index))[](#l9.17) def on_double(self, index): print("double", self.get(index))[](#l9.18)
scrolled_list.append("Item %02d" % i)[](#l9.25)
--- a/Lib/idlelib/ToolTip.py +++ b/Lib/idlelib/ToolTip.py @@ -76,14 +76,21 @@ class ListboxToolTip(ToolTipBase): for item in self.items: listbox.insert(END, item) -def main():
+def _tooltip(parent): root = Tk()
- b = Button(root, text="Hello", command=root.destroy)
- b.pack()
- root.update()
- tip = ListboxToolTip(b, ["Hello", "world"])
- root.title("Test tooltip")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- label = Label(root, text="Place your mouse over buttons")
- label.pack()
- button1 = Button(root, text="Button 1")
- button2 = Button(root, text="Button 2")
- button1.pack()
- button2.pack()
- ToolTip(button1, "This is calltip text for button1.")
- ListboxToolTip(button2, ["This is","calltip text","for button2"]) root.mainloop() if name == 'main':
--- a/Lib/idlelib/TreeWidget.py +++ b/Lib/idlelib/TreeWidget.py @@ -448,29 +448,27 @@ class ScrolledCanvas: return "break" -# Testing functions - -def test():
- from idlelib import PyShell
- root = Toplevel(PyShell.root)
- root.configure(bd=0, bg="yellow")
- root.focus_set()
- root = Tk()
- root.title("Test TreeWidget")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1) test with scrollable canvas
- sc.frame.pack(expand=1, fill="both", side=LEFT)
- item = FileTreeItem(os.getcwd()) node = TreeNode(sc.canvas, None, item) node.expand() -def test2():
- canvas.pack(expand=0, fill="both", side=RIGHT)
- item = FileTreeItem(os.getcwd()) node = TreeNode(canvas, None, item) node.update()
--- a/Lib/idlelib/WidgetRedirector.py +++ b/Lib/idlelib/WidgetRedirector.py @@ -104,10 +104,12 @@ class OriginalCommand: return self.tk_call(self.orig_and_operation + args) -def main(): +def _widget_redirector(parent): root = Tk()
- root.title("Test WidgetRedirector")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- text = Text(root) text.pack() text.focus_set() redir = WidgetRedirector(text) @@ -117,10 +119,7 @@ def main(): previous_tcl_fcn(*args) previous_tcl_fcn = redir.register("insert", my_insert) root.mainloop()
- redir.unregister("insert") # runs after first 'close window'
- redir.close()
- root.mainloop()
- root.destroy()
--- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/aboutDialog.py @@ -12,11 +12,16 @@ class AboutDialog(Toplevel): """Modal about dialog for idle """
- def init(self, parent, title, _htest=False):
"""[](#l13.9)
_htest - bool, change box location when running htest[](#l13.10)
"""[](#l13.11) Toplevel.__init__(self, parent)[](#l13.12) self.configure(borderwidth=5)[](#l13.13)
self.geometry("+%d+%d" % (parent.winfo_rootx()+30,[](#l13.14)
parent.winfo_rooty()+30))[](#l13.15)
# place dialog below parent if running htest[](#l13.16)
self.geometry("+%d+%d" % ([](#l13.17)
parent.winfo_rootx()+30,[](#l13.18)
parent.winfo_rooty()+(30 if not _htest else 100)))[](#l13.19) self.bg = "#707070"[](#l13.20) self.fg = "#ffffff"[](#l13.21) self.CreateWidgets()[](#l13.22)
--- a/Lib/idlelib/configHelpSourceEdit.py +++ b/Lib/idlelib/configHelpSourceEdit.py @@ -8,13 +8,14 @@ import tkinter.messagebox as tkMessageBo import tkinter.filedialog as tkFileDialog class GetHelpSourceDialog(Toplevel):
- 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[](#l14.15) """[](#l14.16) Toplevel.__init__(self, parent)[](#l14.17) self.configure(borderwidth=5)[](#l14.18)
@@ -31,12 +32,14 @@ class GetHelpSourceDialog(Toplevel): 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:[](#l14.23)
self.geometry("+%d+%d" %[](#l14.24)
((parent.winfo_rootx() + ((parent.winfo_width()/2)[](#l14.25)
-(self.winfo_reqwidth()/2)),[](#l14.26)
parent.winfo_rooty() + ((parent.winfo_height()/2)[](#l14.27)
-(self.winfo_reqheight()/2)))))[](#l14.28)
#centre dialog over parent. below parent if running htest.[](#l14.29)
self.geometry([](#l14.30)
"+%d+%d" % ([](#l14.31)
parent.winfo_rootx() +[](#l14.32)
(parent.winfo_width()/2 - self.winfo_reqwidth()/2),[](#l14.33)
parent.winfo_rooty() +[](#l14.34)
((parent.winfo_height()/2 - self.winfo_reqheight()/2)[](#l14.35)
if not _htest else 150)))[](#l14.36) self.deiconify() #geometry set, unhide[](#l14.37) self.bind('<Return>', self.Ok)[](#l14.38) self.wait_window()[](#l14.39)
@@ -159,11 +162,5 @@ class GetHelpSourceDialog(Toplevel): self.destroy() if name == 'main':
- #test the dialog
- root = Tk()
- def run():
keySeq = ''[](#l14.47)
dlg = GetHelpSourceDialog(root, 'Get Help Source')[](#l14.48)
print(dlg.result)[](#l14.49)
- Button(root,text='Dialog', command=run).pack()
- root.mainloop()
--- a/Lib/idlelib/dynOptionMenuWidget.py +++ b/Lib/idlelib/dynOptionMenuWidget.py @@ -2,9 +2,10 @@ OptionMenu widget modified to allow dynamic menu reconfiguration and setting of highlightthickness """ -from tkinter import OptionMenu -from tkinter import _setit +from tkinter import OptionMenu, _setit, Tk, StringVar, Button + import copy +import re class DynOptionMenu(OptionMenu): """ @@ -33,3 +34,24 @@ class DynOptionMenu(OptionMenu): command=_setit(self.variable,item,self.command)) if value: self.variable.set(value) + +def _dyn_option_menu(parent):
- root = Tk()
- root.title("Tets dynamic option menu")
- var = StringVar(root)
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- var.set("Old option set") #Set the default value
- dyn = DynOptionMenu(root,var, "old1","old2","old3","old4")
- dyn.pack()
--- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -35,17 +35,51 @@ import tkinter as tk AboutDialog_spec = { 'file': 'aboutDialog',
- 'kwds': {'title': 'aboutDialog test',
'_htest': True,[](#l16.10)
},[](#l16.11)
- 'msg': "Test every button. Ensure Python, TK and IDLE versions "
"are correctly displayed.\n [Close] to exit.",[](#l16.13)
}[](#l16.14)
- 'file': 'CallTipWindow',
- 'kwds': {},
- 'msg': "Typing '(' should display a calltip.\n"
} +_class_browser_spec = {"Typing ') should hide the calltip.\n"[](#l16.20)
- 'file': 'ClassBrowser',
- 'kwds': {},
- 'msg': "Inspect names of module, class(with superclass if "
"applicable), methods and functions.\nToggle nested items."[](#l16.27)
"\nN.S: Double click on items does not work",[](#l16.28)
}[](#l16.29)
- 'msg': "The text is sample Python code.\n"
"Ensure components like comments, keywords, builtins,\n"[](#l16.38)
"string, definitions, and break are correctly colored.\n"[](#l16.39)
} +_dyn_option_menu_spec = {"The default color scheme is in idlelib/config-highlight.def"[](#l16.40)
- 'file': 'dynOptionMenuWidget',
- 'kwds': {},
- 'msg': "Select one of the many options in the 'old option set'.\n"
"Click the button to change the option set.\n"[](#l16.47)
"Select one of the many options in the 'new option set'."[](#l16.48)
- }
+ +#_editor_window_spec = { +# 'file': 'EditorWindow', +# 'kwds': {}, +# 'msg': "Test editor functions of interest" +# } + GetCfgSectionNameDialog_spec = { 'file': 'configSectionNameDialog', 'kwds': {'title':'Get Name', @@ -54,7 +88,19 @@ GetCfgSectionNameDialog_spec = { '_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]",[](#l16.64)
"Close 'Get Name' with a valid entry (printed to Shell), "[](#l16.65)
"[Cancel], or [X]",[](#l16.66)
- }
- 'file': 'configHelpSourceEdit',
- 'kwds': {'title': 'Get helpsource',
'_htest': True},[](#l16.71)
- 'msg': "Enter menu item name and help file path\n "
"<nothing> and more than 30 chars are invalid menu item names.\n"[](#l16.73)
"<nothing>, file does not exist are invalid path items.\n"[](#l16.74)
"Test for incomplete web address for help file path.\n"[](#l16.75)
"A valid entry will be printed to shell with [0k].\n"[](#l16.76)
} _help_dialog_spec = { @@ -63,30 +109,152 @@ GetCfgSectionNameDialog_spec = { 'msg': "If the help text displays, this works" } -def run(test):"[Cancel] will print None to shell",[](#l16.77)
- 'file': 'IOBinding',
- 'kwds': {},
- 'msg': "Test the following bindings\n"
"<Control-o> to display open window from file dialog.\n"[](#l16.91)
"<Control-s> to save the file\n"[](#l16.92)
- 'file': 'MultiCall',
- 'kwds': {},
- 'msg': "The following actions should trigger a print to console.\n"
"Entering and leaving the text area, key entry, <Control-Key>,\n"[](#l16.100)
"<Alt-Key-a>, <Control-Key-a>, <Alt-Control-Key-a>, \n"[](#l16.101)
"<Control-Button-1>, <Alt-Button-1> and focussing out of the window\n"[](#l16.102)
"are sequences to be tested."[](#l16.103)
- }
- 'file': 'MultiStatusBar',
- 'kwds': {},
- 'msg': "Ensure presence of multi-status bar below text area.\n"
"Click 'Update Status' to change the multi-status text"[](#l16.110)
- }
- 'file': 'ObjectBrowser',
- 'kwds': {},
- 'msg': "Double click on items upto the lowest level.\n"
"Attributes of the objects and related information "[](#l16.117)
"will be displayed side-by-side at each level."[](#l16.118)
- }
- 'file': 'PathBrowser',
- 'kwds': {},
- 'msg': "Test for correct display of all paths in sys.path."
"\nToggle nested items upto the lowest level."[](#l16.125)
"\nN.S: Double click on items does not work."[](#l16.126)
- }
- 'file': 'ScrolledList',
- 'kwds': {},
- 'msg': "You should see a scrollable list of items\n"
"Selecting an item will print it to console.\n"[](#l16.133)
"Double clicking an item will print it to console\n"[](#l16.134)
"Right click on an item will display a popup."[](#l16.135)
- }
- 'file': 'tabbedpages',
- 'kwds': {},
- 'msg': "Toggle between the two tabs 'foo' and 'bar'\n"
"Add a tab by entering a suitable name for it.\n"[](#l16.142)
"Remove an existing tab by entering its name.\n"[](#l16.143)
"Remove all existing tabs.\n"[](#l16.144)
"<nothing> is an invalid add page and remove page name.\n"[](#l16.145)
- }
- 'file': 'textView',
- 'kwds': {'title': 'Test textView',
'text':'The quick brown fox jumps over the lazy dog.\n'*35,[](#l16.151)
'_htest': True},[](#l16.152)
- 'msg': "Test for read-only property of text.\n"
"Text is selectable. Window is scrollable.",[](#l16.154)
}[](#l16.155)
- 'file': 'ToolTip',
- 'kwds': {},
- 'msg': "Place mouse cursor over both the buttons\n"
"A tooltip should appear with some text."[](#l16.161)
- }
- 'file': 'TreeWidget',
- 'kwds': {},
- 'msg': "You should see two canvas' side-by-side.\n"
"The left canvas is scrollable.\n"[](#l16.168)
"The right canvas is not scrollable.\n"[](#l16.169)
"Click on folders upto to the lowest level."[](#l16.170)
- }
+ +_widget_redirector_spec = {
+ +def run(test=None): root = tk.Tk()
- test_list = [] # List of tuples of the form (spec, kwds, callable widget)
- if test:
test_spec = globals()[test.__name__ + '_spec'][](#l16.186)
test_spec['name'] = test.__name__[](#l16.187)
test_kwds = test_spec['kwds'][](#l16.188)
test_kwds['parent'] = root[](#l16.189)
test_list.append((test_spec, test_kwds, test))[](#l16.190)
- else:
for k, d in globals().items():[](#l16.192)
if k.endswith('_spec'):[](#l16.193)
test_name = k[:-5][](#l16.194)
test_spec = d[](#l16.195)
test_spec['name'] = test_name[](#l16.196)
test_kwds = test_spec['kwds'][](#l16.197)
test_kwds['parent'] = root[](#l16.198)
mod = import_module('idlelib.' + test_spec['file'])[](#l16.199)
test = getattr(mod, test_name)[](#l16.200)
test_list.append((test_spec, test_kwds, test))[](#l16.201)
- def next():
nonlocal help_string, test_name, callable_object, test_kwds[](#l16.210)
if len(test_list) == 1:[](#l16.211)
next_button.pack_forget()[](#l16.212)
test_spec, test_kwds, test = test_list.pop()[](#l16.213)
help_string.set(test_spec['msg'])[](#l16.214)
test_name.set('test ' + test_spec['name'])[](#l16.215)
callable_object = test[](#l16.216)
widget = test(**test_kwds)[](#l16.220)
widget = callable_object(**test_kwds)[](#l16.221) try:[](#l16.222) print(widget.result)[](#l16.223) except AttributeError:[](#l16.224) pass[](#l16.225)
- tk.Label(root, text=test_spec['msg'], justify='left').pack()
- tk.Button(root, text='Test ' + test.name, command=run_test).pack()
- label = tk.Label(root, textvariable=help_string, justify='left')
- label.pack()
- button = tk.Button(root, textvariable=test_name, command=run_test)
- button.pack()
- next_button = tk.Button(root, text="Next", command=next)
- next_button.pack()
+ root.mainloop() -def runall():
- "Run all tests. Quick and dirty version."
- for k, d in globals().items():
if k.endswith('_spec'):[](#l16.243)
mod = import_module('idlelib.' + d['file'])[](#l16.244)
test = getattr(mod, k[:-5])[](#l16.245)
run(test)[](#l16.246)
--- a/Lib/idlelib/tabbedpages.py +++ b/Lib/idlelib/tabbedpages.py @@ -467,9 +467,12 @@ class TabbedPageSet(Frame): self._tab_set.set_selected_tab(page_name) -if name == 'main': +def _tabbed_pages(parent): # test dialog root=Tk()
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 175))
- root.title("Test tabbed pages") tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'], n_rows=0, expand_tabs=False, )
@@ -488,3 +491,8 @@ if name == 'main': labelPgName.pack(padx=5) entryPgName.pack(padx=5) root.mainloop() + + +if name == 'main':
--- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -9,15 +9,17 @@ class TextViewer(Toplevel): """A simple text viewer dialog for IDLE """
- 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[](#l18.11) """[](#l18.12) Toplevel.__init__(self, parent)[](#l18.13) self.configure(borderwidth=5)[](#l18.14)
# place dialog below parent if running htest[](#l18.15) self.geometry("=%dx%d+%d+%d" % (625, 500,[](#l18.16)
parent.winfo_rootx() + 10,[](#l18.17)
parent.winfo_rooty() + 10))[](#l18.18)
parent.winfo_rootx() + 10,[](#l18.19)
parent.winfo_rooty() + (10 if not _htest else 100)))[](#l18.20) #elguavas - config placeholders til config stuff completed[](#l18.21) self.bg = '#ffffff'[](#l18.22) self.fg = '#000000'[](#l18.23)
@@ -74,24 +76,6 @@ def view_file(parent, title, filename, e 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()[](#l18.35)
- btn1 = Button(root, text='view_text',
command=lambda:view_text(root, 'view_text', text))[](#l18.37)
- btn1.pack(side=LEFT)
- btn2 = Button(root, text='view_file',
command=lambda:view_file(root, 'view_file', filename))[](#l18.40)
- btn2.pack(side=LEFT)
- btn3 = Button(root, text='nonmodal view_text',
command=lambda:view_text(root, 'nonmodal view_text', text,[](#l18.43)
modal=False))[](#l18.44)
- btn3.pack(side=LEFT)
- close = Button(root, text='Close', command=root.destroy)
- close.pack(side=RIGHT)
- root.mainloop()