Refine geometry of idlelib htests (and a few other fix-ups).

This commit is contained in:
Terry Jan Reedy 2016-07-10 17:28:10 -04:00
parent cd5e388c39
commit a748032653
19 changed files with 52 additions and 58 deletions

View File

@ -138,8 +138,8 @@ def _calltip_window(parent): # htest #
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")

View File

@ -259,8 +259,8 @@ def _color_delegator(parent): # htest #
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 @@ if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_colorizer',
verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(_color_delegator)

View File

@ -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 @@ def _object_browser(parent): # htest #
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)

View File

@ -38,8 +38,8 @@ def _dyn_option_menu(parent): # htest #
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)

View File

@ -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 @@ def _grep_dialog(parent): # htest #
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)

View File

@ -21,7 +21,7 @@ class ConfigDialogTest(unittest.TestCase):
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()

View File

@ -535,8 +535,8 @@ def _io_binding(parent): # htest #
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

View File

@ -417,8 +417,8 @@ def MultiCallCreator(widget):
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]):

View File

@ -57,7 +57,6 @@ class Percolator:
def _percolator(parent): # htest #
import tkinter as tk
import re
class Tracer(Delegator):
def __init__(self, name):
@ -74,8 +73,8 @@ def _percolator(parent): # htest #
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

View File

@ -152,12 +152,11 @@ class OriginalCommand:
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 @@ if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_redirector',
verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(_widget_redirector)

View File

@ -207,8 +207,8 @@ def _replace_dialog(parent): # htest #
"""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 @@ def _replace_dialog(parent): # htest #
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

View File

@ -127,8 +127,8 @@ class ScrolledList:
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))

View File

@ -75,8 +75,8 @@ def _search_dialog(parent): # htest #
'''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 @@ def _search_dialog(parent): # htest #
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)

View File

@ -120,11 +120,11 @@ class VariablesTreeItem(ObjectTreeItem):
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

View File

@ -17,15 +17,14 @@ class MultiStatusBar(Frame):
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")

View File

@ -468,10 +468,9 @@ class TabbedPageSet(Frame):
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,

View File

@ -77,20 +77,19 @@ class ListboxToolTip(ToolTipBase):
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

View File

@ -451,8 +451,8 @@ class ScrolledCanvas:
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)

View File

@ -338,13 +338,12 @@ class CommandSequence(Command):
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 @@ def _undo_delegator(parent): # htest #
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)