[Python-checkins] cpython: Refine geometry of idlelib htests (and a few other fix-ups).
terry.reedy
python-checkins at python.org
Sun Jul 10 17:28:22 EDT 2016
https://hg.python.org/cpython/rev/fdf4d1984659
changeset: 102315:fdf4d1984659
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Sun Jul 10 17:28:10 2016 -0400
summary:
Refine geometry of idlelib htests (and a few other fix-ups).
files:
Lib/idlelib/calltip_w.py | 4 +-
Lib/idlelib/colorizer.py | 5 ++-
Lib/idlelib/debugobj.py | 6 +--
Lib/idlelib/dynoption.py | 4 +-
Lib/idlelib/grep.py | 5 +--
Lib/idlelib/idle_test/test_configdialog.py | 2 +-
Lib/idlelib/iomenu.py | 4 +-
Lib/idlelib/multicall.py | 4 +-
Lib/idlelib/percolator.py | 5 +--
Lib/idlelib/redirector.py | 6 ++--
Lib/idlelib/replace.py | 6 ++--
Lib/idlelib/scrolledlist.py | 4 +-
Lib/idlelib/search.py | 7 ++--
Lib/idlelib/stackviewer.py | 6 ++--
Lib/idlelib/statusbar.py | 9 ++---
Lib/idlelib/tabbedpages.py | 5 +--
Lib/idlelib/tooltip.py | 15 ++++-----
Lib/idlelib/tree.py | 4 +-
Lib/idlelib/undo.py | 9 ++---
19 files changed, 52 insertions(+), 58 deletions(-)
diff --git a/Lib/idlelib/calltip_w.py b/Lib/idlelib/calltip_w.py
--- a/Lib/idlelib/calltip_w.py
+++ b/Lib/idlelib/calltip_w.py
@@ -138,8 +138,8 @@
top = Toplevel(parent)
top.title("Test calltips")
- top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
- parent.winfo_rooty() + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("200x100+%d+%d" % (x + 250, y + 175))
text = Text(top)
text.pack(side=LEFT, fill=BOTH, expand=1)
text.insert("insert", "string.split")
diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py
--- a/Lib/idlelib/colorizer.py
+++ b/Lib/idlelib/colorizer.py
@@ -259,8 +259,8 @@
top = Toplevel(parent)
top.title("Test ColorDelegator")
- top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
- parent.winfo_rooty() + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("200x100+%d+%d" % (x + 250, y + 175))
source = "if somename: x = 'abc' # comment\nprint\n"
text = Text(top, background="white")
text.pack(expand=1, fill="both")
@@ -276,5 +276,6 @@
import unittest
unittest.main('idlelib.idle_test.test_colorizer',
verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_color_delegator)
diff --git a/Lib/idlelib/debugobj.py b/Lib/idlelib/debugobj.py
--- a/Lib/idlelib/debugobj.py
+++ b/Lib/idlelib/debugobj.py
@@ -9,8 +9,6 @@
# XXX TO DO:
# - for classes/modules, add "open source" to object browser
-import re
-
from idlelib.tree import TreeItem, TreeNode, ScrolledCanvas
from reprlib import Repr
@@ -127,8 +125,8 @@
from tkinter import Toplevel
top = Toplevel(parent)
top.title("Test debug object browser")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x + 100, y + 175))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x + 100, y + 175))
top.configure(bd=0, bg="yellow")
top.focus_set()
sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
diff --git a/Lib/idlelib/dynoption.py b/Lib/idlelib/dynoption.py
--- a/Lib/idlelib/dynoption.py
+++ b/Lib/idlelib/dynoption.py
@@ -38,8 +38,8 @@
top = Toplevel(parent)
top.title("Tets dynamic option menu")
- top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
- parent.winfo_rooty() + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("200x100+%d+%d" % (x + 250, y + 175))
top.focus_set()
var = StringVar(top)
diff --git a/Lib/idlelib/grep.py b/Lib/idlelib/grep.py
--- a/Lib/idlelib/grep.py
+++ b/Lib/idlelib/grep.py
@@ -1,6 +1,5 @@
import os
import fnmatch
-import re # for htest
import sys
from tkinter import StringVar, BooleanVar, Checkbutton # for GrepDialog
from idlelib import searchengine
@@ -134,8 +133,8 @@
from tkinter import Toplevel, Text, Button, SEL, END
top = Toplevel(parent)
top.title("Test GrepDialog")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x, y + 175))
flist = PyShellFileList(top)
text = Text(top, height=5)
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -21,7 +21,7 @@
cls.root.destroy()
del cls.root
- def test_dialog(self):
+ def test_configdialog(self):
d = ConfigDialog(self.root, 'Test', _utest=True)
d.remove_var_callbacks()
diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py
--- a/Lib/idlelib/iomenu.py
+++ b/Lib/idlelib/iomenu.py
@@ -535,8 +535,8 @@
root = Toplevel(parent)
root.title("Test IOBinding")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ root.geometry("+%d+%d" % (x, y + 175))
class MyEditWin:
def __init__(self, text):
self.text = text
diff --git a/Lib/idlelib/multicall.py b/Lib/idlelib/multicall.py
--- a/Lib/idlelib/multicall.py
+++ b/Lib/idlelib/multicall.py
@@ -417,8 +417,8 @@
def _multi_call(parent): # htest #
top = tkinter.Toplevel(parent)
top.title("Test MultiCall")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x, y + 175))
text = MultiCallCreator(tkinter.Text)(top)
text.pack()
def bindseq(seq, n=[0]):
diff --git a/Lib/idlelib/percolator.py b/Lib/idlelib/percolator.py
--- a/Lib/idlelib/percolator.py
+++ b/Lib/idlelib/percolator.py
@@ -57,7 +57,6 @@
def _percolator(parent): # htest #
import tkinter as tk
- import re
class Tracer(Delegator):
def __init__(self, name):
@@ -74,8 +73,8 @@
box = tk.Toplevel(parent)
box.title("Test Percolator")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- box.geometry("+%d+%d" % (x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ box.geometry("+%d+%d" % (x, y + 175))
text = tk.Text(box)
p = Percolator(text)
pin = p.insertfilter
diff --git a/Lib/idlelib/redirector.py b/Lib/idlelib/redirector.py
--- a/Lib/idlelib/redirector.py
+++ b/Lib/idlelib/redirector.py
@@ -152,12 +152,11 @@
def _widget_redirector(parent): # htest #
from tkinter import Toplevel, Text
- import re
top = Toplevel(parent)
top.title("Test WidgetRedirector")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x, y + 175))
text = Text(top)
text.pack()
text.focus_set()
@@ -171,5 +170,6 @@
import unittest
unittest.main('idlelib.idle_test.test_redirector',
verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_widget_redirector)
diff --git a/Lib/idlelib/replace.py b/Lib/idlelib/replace.py
--- a/Lib/idlelib/replace.py
+++ b/Lib/idlelib/replace.py
@@ -207,8 +207,8 @@
"""htest wrapper function"""
box = Toplevel(parent)
box.title("Test ReplaceDialog")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- box.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ box.geometry("+%d+%d" % (x, y + 175))
# mock undo delegator methods
def undo_block_start():
@@ -234,7 +234,7 @@
if __name__ == '__main__':
import unittest
- unittest.main('idlelib.idle_test.test_replacedialog',
+ unittest.main('idlelib.idle_test.test_replace',
verbosity=2, exit=False)
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/scrolledlist.py b/Lib/idlelib/scrolledlist.py
--- a/Lib/idlelib/scrolledlist.py
+++ b/Lib/idlelib/scrolledlist.py
@@ -127,8 +127,8 @@
def _scrolled_list(parent): # htest #
top = Toplevel(parent)
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x+200, y + 175))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x+200, y + 175))
class MyScrolledList(ScrolledList):
def fill_menu(self): self.menu.add_command(label="right click")
def on_select(self, index): print("select", self.get(index))
diff --git a/Lib/idlelib/search.py b/Lib/idlelib/search.py
--- a/Lib/idlelib/search.py
+++ b/Lib/idlelib/search.py
@@ -75,8 +75,8 @@
'''Display search test box.'''
box = Toplevel(parent)
box.title("Test SearchDialog")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- box.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ box.geometry("+%d+%d" % (x, y + 175))
text = Text(box, inactiveselectbackground='gray')
text.pack()
text.insert("insert","This is a sample string.\n"*5)
@@ -91,7 +91,8 @@
if __name__ == '__main__':
import unittest
- unittest.main('idlelib.idle_test.test_searchdialog',
+ unittest.main('idlelib.idle_test.test_search',
verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_search_dialog)
diff --git a/Lib/idlelib/stackviewer.py b/Lib/idlelib/stackviewer.py
--- a/Lib/idlelib/stackviewer.py
+++ b/Lib/idlelib/stackviewer.py
@@ -120,11 +120,11 @@
sublist.append(item)
return sublist
-def _stack_viewer(parent):
+def _stack_viewer(parent): # htest #
top = tk.Toplevel(parent)
top.title("Test StackViewer")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x + 50, y + 175))
flist = PyShellFileList(top)
try: # to obtain a traceback object
intentional_name_error
diff --git a/Lib/idlelib/statusbar.py b/Lib/idlelib/statusbar.py
--- a/Lib/idlelib/statusbar.py
+++ b/Lib/idlelib/statusbar.py
@@ -17,15 +17,14 @@
label.config(width=width)
label.config(text=text)
-def _multistatus_bar(parent):
- import re
+def _multistatus_bar(parent): # htest #
from tkinter import Toplevel, Frame, Text, Button
top = Toplevel(parent)
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d" %(x, y + 150))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" %(x, y + 175))
top.title("Test multistatus bar")
frame = Frame(top)
- text = Text(frame)
+ text = Text(frame, height=5, width=40)
text.pack()
msb = MultiStatusBar(frame)
msb.set_label("one", "hello")
diff --git a/Lib/idlelib/tabbedpages.py b/Lib/idlelib/tabbedpages.py
--- a/Lib/idlelib/tabbedpages.py
+++ b/Lib/idlelib/tabbedpages.py
@@ -468,10 +468,9 @@
self._tab_set.set_selected_tab(page_name)
def _tabbed_pages(parent): # htest #
- import re
top=Toplevel(parent)
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x, y + 175))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x, y + 175))
top.title("Test tabbed pages")
tabPage=TabbedPageSet(top, page_names=['Foobar','Baz'], n_rows=0,
expand_tabs=False,
diff --git a/Lib/idlelib/tooltip.py b/Lib/idlelib/tooltip.py
--- a/Lib/idlelib/tooltip.py
+++ b/Lib/idlelib/tooltip.py
@@ -77,20 +77,19 @@
listbox.insert(END, item)
def _tooltip(parent): # htest #
- root = Tk()
- 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")
+ top = Toplevel(parent)
+ top.title("Test tooltip")
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x, y + 150))
+ label = Label(top, text="Place your mouse over buttons")
label.pack()
- button1 = Button(root, text="Button 1")
- button2 = Button(root, text="Button 2")
+ button1 = Button(top, text="Button 1")
+ button2 = Button(top, text="Button 2")
button1.pack()
button2.pack()
ToolTip(button1, "This is tooltip text for button1.")
ListboxToolTip(button2, ["This is","multiple line",
"tooltip text","for button2"])
- root.mainloop()
if __name__ == '__main__':
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/tree.py b/Lib/idlelib/tree.py
--- a/Lib/idlelib/tree.py
+++ b/Lib/idlelib/tree.py
@@ -451,8 +451,8 @@
def _tree_widget(parent): # htest #
top = Toplevel(parent)
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- top.geometry("+%d+%d"%(x+50, y+175))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ top.geometry("+%d+%d" % (x+50, y+175))
sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both", side=LEFT)
item = FileTreeItem(ICONDIR)
diff --git a/Lib/idlelib/undo.py b/Lib/idlelib/undo.py
--- a/Lib/idlelib/undo.py
+++ b/Lib/idlelib/undo.py
@@ -338,13 +338,12 @@
def _undo_delegator(parent): # htest #
- import re
from tkinter import Toplevel, Text, Button
from idlelib.percolator import Percolator
undowin = Toplevel(parent)
undowin.title("Test UndoDelegator")
- width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- undowin.geometry("+%d+%d"%(x, y + 175))
+ x, y = map(int, parent.geometry().split('+')[1:])
+ undowin.geometry("+%d+%d" % (x, y + 175))
text = Text(undowin, height=10)
text.pack()
@@ -362,7 +361,7 @@
if __name__ == "__main__":
import unittest
- unittest.main('idlelib.idle_test.test_undo', verbosity=2,
- exit=False)
+ unittest.main('idlelib.idle_test.test_undo', verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_undo_delegator)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list