Skip to content

Commit

Permalink
pythongh-66819: More IDLE htest updates(3) (pythonGH-112683)
Browse files Browse the repository at this point in the history
Revise spec-callable pairs from percolator to end.
(cherry picked from commit 5a1b531)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
  • Loading branch information
terryjreedy authored and miss-islington committed Dec 4, 2023
1 parent 73411ea commit fd0ba05
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Lib/idlelib/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def copy_strip():
out.write(line.rstrip() + b'\n')
print(f'{src} copied to {dst}')

def show_idlehelp(parent):
def _helpwindow(parent):
"Create HelpWindow; called from Idle Help event handler."
filename = join(abspath(dirname(__file__)), 'help.html')
if not isfile(filename):
Expand All @@ -291,4 +291,4 @@ def show_idlehelp(parent):
main('idlelib.idle_test.test_help', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(show_idlehelp)
run(_helpwindow)
16 changes: 8 additions & 8 deletions Lib/idlelib/idle_test/htest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"<Escape>, [Cancel], or [X] prints None to shell"
}

_helpwindow_spec = {
'file': 'help',
'kwds': {},
'msg': "If the help text displays, this works.\n"
"Text is selectable. Window is scrollable."
}

_io_binding_spec = {
'file': 'iomenu',
'kwds': {},
Expand Down Expand Up @@ -312,14 +319,7 @@
"Right clicking an item will display a popup."
}

show_idlehelp_spec = {
'file': 'help',
'kwds': {},
'msg': "If the help text displays, this works.\n"
"Text is selectable. Window is scrollable."
}

_stack_viewer_spec = {
_stackbrowser_spec = {
'file': 'stackviewer',
'kwds': {},
'msg': "A stacktrace for a NameError exception.\n"
Expand Down
12 changes: 6 additions & 6 deletions Lib/idlelib/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def delete(self, *args):
print(self.name, ": delete", args)
self.delegate.delete(*args)

box = tk.Toplevel(parent)
box.title("Test Percolator")
top = tk.Toplevel(parent)
top.title("Test Percolator")
x, y = map(int, parent.geometry().split('+')[1:])
box.geometry("+%d+%d" % (x, y + 175))
text = tk.Text(box)
top.geometry("+%d+%d" % (x, y + 175))
text = tk.Text(top)
p = Percolator(text)
pin = p.insertfilter
pout = p.removefilter
Expand All @@ -104,10 +104,10 @@ def toggle2():

text.pack()
var1 = tk.IntVar(parent)
cb1 = tk.Checkbutton(box, text="Tracer1", command=toggle1, variable=var1)
cb1 = tk.Checkbutton(top, text="Tracer1", command=toggle1, variable=var1)
cb1.pack()
var2 = tk.IntVar(parent)
cb2 = tk.Checkbutton(box, text="Tracer2", command=toggle2, variable=var2)
cb2 = tk.Checkbutton(top, text="Tracer2", command=toggle2, variable=var2)
cb2.pack()

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion Lib/idlelib/scrolledlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def _scrolled_list(parent): # htest #
top = Toplevel(parent)
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))
Expand All @@ -143,7 +144,7 @@ def on_double(self, index): print("double", self.get(index))

if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_scrolledlist', verbosity=2,)
main('idlelib.idle_test.test_scrolledlist', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_scrolled_list)
4 changes: 2 additions & 2 deletions Lib/idlelib/stackviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def setfunction(value, key=key, object=self.object):
return sublist


def _stack_viewer(parent): # htest #
def _stackbrowser(parent): # htest #
from idlelib.pyshell import PyShellFileList
top = tk.Toplevel(parent)
top.title("Test StackViewer")
Expand All @@ -131,4 +131,4 @@ def _stack_viewer(parent): # htest #
main('idlelib.idle_test.test_stackviewer', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_stack_viewer)
run(_stackbrowser)
14 changes: 7 additions & 7 deletions Lib/idlelib/undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,23 +339,23 @@ def bump_depth(self, incr=1):
def _undo_delegator(parent): # htest #
from tkinter import Toplevel, Text, Button
from idlelib.percolator import Percolator
undowin = Toplevel(parent)
undowin.title("Test UndoDelegator")
top = Toplevel(parent)
top.title("Test UndoDelegator")
x, y = map(int, parent.geometry().split('+')[1:])
undowin.geometry("+%d+%d" % (x, y + 175))
top.geometry("+%d+%d" % (x, y + 175))

text = Text(undowin, height=10)
text = Text(top, height=10)
text.pack()
text.focus_set()
p = Percolator(text)
d = UndoDelegator()
p.insertfilter(d)

undo = Button(undowin, text="Undo", command=lambda:d.undo_event(None))
undo = Button(top, text="Undo", command=lambda:d.undo_event(None))
undo.pack(side='left')
redo = Button(undowin, text="Redo", command=lambda:d.redo_event(None))
redo = Button(top, text="Redo", command=lambda:d.redo_event(None))
redo.pack(side='left')
dump = Button(undowin, text="Dump", command=lambda:d.dump_event(None))
dump = Button(top, text="Dump", command=lambda:d.dump_event(None))
dump.pack(side='left')

if __name__ == "__main__":
Expand Down

0 comments on commit fd0ba05

Please sign in to comment.