8000 bpo-1529353: IDLE: squeeze large output in the shell by taleinat · Pull Request #7626 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1529353: IDLE: squeeze large output in the shell #7626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a7e130a
bpo-1529353: update the Squeezer extension and its tests
taleinat Jun 11, 2018
0af6a62
bpo-1529353: use idlelib.textview for previewing squeezed output
taleinat Aug 12, 2018
71fb2c1
Merge branch 'master' into bpo-1529353
taleinat Aug 12, 2018
bda6572
Refactor Squeezer from an extension to an integral part of IDLE.
taleinat Aug 13, 2018
53e74d9
Merge branch 'master' into bpo-1529353
taleinat Aug 27, 2018
902091e
Update Squeezer's tests given the latest changes
taleinat Aug 27, 2018
6d7035b
add ability to control text wrapping in IDLE's text viewer
taleinat Aug 28, 2018
45fb1a6
ask for user confirmation before expanding huge squeezed outputs
taleinat Aug 28, 2018
18106e8
increase Squeezer's default auto-squeeze-min-lines from 30 to 50
taleinat Aug 28, 2018
2c795e3
move 'copy' and 'preview' squeezed output actions to a context menu
taleinat Aug 28, 2018
1a1288a
Squeezer: rename "preview" to "view"
taleinat Aug 28, 2018
f753b37
Squeezer: remove tooltip configuration options (delay set to 80ms)
taleinat Aug 30, 2018
6087d3f
Squeezer: remove expand/view-last-squeezed events
taleinat Aug 30, 2018
b7d27cb
Squeezer: make view window non-modal and add horizontal scrollbar
taleinat Aug 30, 2018
ce07987
Merge remote-tracking branch 'origin/master' into pr_7626.
terryjreedy Sep 25, 2018
9676991
Correct error in merge resolution.
terryjreedy Sep 25, 2018
e768e0f
Make test_squeezer runnable.
terryjreedy Sep 25, 2018
fcc9084
bpo-1529353: explicitly create root Tk() objects in tests
taleinat Sep 25, 2018
468d9ec
bpo-1529353: reformat doc-strings as PEP8 and rename test classes
taleinat Sep 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add ability to control text wrapping in IDLE's text viewer
  • Loading branch information
taleinat committed Aug 28, 2018
commit 6d7035bb48b2bc0abf49577c6b00c60b3b420831
7 changes: 5 additions & 2 deletions Lib/idlelib/idle_test/test_textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class TextFrameTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
"By itself, this tests that file parsed without exception."
cls.root = root = Tk()
root.withdraw()
cls.frame = tv.TextFrame(root, 'test text')
Expand Down Expand Up @@ -126,11 +125,15 @@ def test_bad_file(self):
def test_bad_encoding(self):
p = os.path
fn = p.abspath(p.join(p.dirname(__file__), '..', 'CREDITS.txt'))
tv.showerror.title = None
view = tv.view_file(root, 'Title', fn, 'ascii', modal=False)
self.assertIsNone(view)
self.assertEqual(tv.showerror.title, 'Unicode Decode Error')

def test_nowrap(self):
view = tv.view_text(root, 'Title', 'test', modal=False, wrap='none')
text_widget = view.viewframe.textframe.text
self.assertEqual(text_widget.cget('wrap'), 'none')


# Call ViewWindow with _utest=True.
class ButtonClickTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/squeezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def preview(self, event):

View the original text in a separate text viewer window.
"""
view_text(self.text, "Squeezed Output Viewer", self.s)
view_text(self.text, "Squeezed Output Viewer", self.s, wrap='none')


class Squeezer:
Expand Down
24 changes: 14 additions & 10 deletions Lib/idlelib/textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TextFrame(Frame):
"Display text with scrollbar."

def __init__(self, parent, rawtext):
def __init__(self, parent, rawtext, wrap='word'):
"""Create a frame for Textview.

parent - parent widget for this frame
Expand All @@ -22,7 +22,7 @@ def __init__(self, parent, rawtext):
self.bg = '#ffffff'
self.fg = '#000000'

self.text = text = Text(self, wrap='word', highlightthickness=0,
self.text = text = Text(self, wrap=wrap, highlightthickness=0,
fg=self.fg, bg=self.bg)
self.scroll = scroll = Scrollbar(self, orient='vertical',
takefocus=False, command=text.yview)
Expand All @@ -37,12 +37,12 @@ def __init__(self, parent, rawtext):

class ViewFrame(Frame):
"Display TextFrame and Close button."
def __init__(self, parent, text):
def __init__(self, parent, text, wrap='word'):
super().__init__(parent)
self.parent = parent
self.bind('<Return>', self.ok)
self.bind('<Escape>', self.ok)
self.textframe = TextFrame(self, text)
self.textframe = TextFrame(self, text, wrap=wrap)
self.button_ok = button_ok = Button(
self, text='Close', command=self.ok, takefocus=False)
self.textframe.pack(side='top', expand=True, fill='both')
Expand All @@ -56,7 +56,7 @@ def ok(self, event=None):
class ViewWindow(Toplevel):
"A simple text viewer dialog for IDLE."

def __init__(self, parent, title, text, modal=True,
def __init__(self, parent, title, text, modal=True, wrap='word',
*, _htest=False, _utest=False):
"""Show the given text in a scrollable window with a 'close' button.

Expand All @@ -66,6 +66,7 @@ def __init__(self, parent, title, text, modal=True,
parent - parent of this dialog
title - string which is title of popup dialog
text - text to display in dialog
wrap - type of text wrapping to use ('word', 'char' or 'none')
_htest - bool; change box location when running htest.
_utest - bool; don't wait_window when running unittest.
"""
Expand All @@ -77,7 +78,7 @@ def __init__(self, parent, title, text, modal=True,
self.geometry(f'=750x500+{x}+{y}')

self.title(title)
self.viewframe = ViewFrame(self, text)
self.viewframe = ViewFrame(self, text, wrap=wrap)
self.protocol("WM_DELETE_WINDOW", self.ok)
self.button_ok = button_ok = Button(self, text='Close',
command=self.ok, takefocus=False)
Expand All @@ -97,20 +98,22 @@ def ok(self, event=None):
self.destroy()


def view_text(parent, title, text, modal=True, _utest=False):
def view_text(parent, title, text, modal=True, wrap='word', _utest=False):
"""Create text viewer for given text.

parent - parent of this dialog
title - string which is the title of popup dialog
text - text to display in this dialog
wrap - type of text wrapping to use ('word', 'char' or 'none')
modal - controls if users can interact with other windows while this
dialog is displayed
_utest - bool; controls wait_window on unittest
"""
return ViewWindow(parent, title, text, modal, _utest=_utest)
return ViewWindow(parent, title, text, modal, wrap=wrap, _utest=_utest)


def view_file(parent, title, filename, encoding, modal=True, _utest=False):
def view_file(parent, title, filename, encoding, modal=True, wrap='word',
_utest=False):
"""Create text viewer for text in filename.

Return error message if file cannot be read. Otherwise calls view_text
Expand All @@ -128,7 +131,8 @@ def view_file(parent, title, filename, encoding, modal=True, _utest=False):
message=str(err),
parent=parent)
else:
return view_text(parent, title, contents, modal, _utest=_utest)
return view_text(parent, title, contents, modal, wrap=wrap,
_utest=_utest)
return None


Expand Down
0