-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Squeezer - squeeze large output in IDLE's shell #43728
Comments
Here is my improved version of Squeezer - the IDLE Changes:
I've been working this vesion without a hitch for Attached:
One minor note - the 'middle click to copy' didn't work For more info on the clipboard issue, see: |
Logged In: YES OK, thanks. Please take a look at the two diffs you |
Logged In: YES Uploaded unified diffs instead of standard diffs. Probably Also 2 changes:
|
Logged In: YES Ah, that's better. Thanks. |
Delete the patch to configHandler.py, implemented with Patch 1650174. |
"Test needed"? I'll need a bit of guidance on this. Has there been a change of policy of which I'm not aware, that patches Much of IDLE doesn't include tests, e.g. the RPC code. There's a comment In any case, if someone can suggest a simple approach to test Squeezer |
Tal, If someone is already working on adding tests for IDLE, please revert |
Daniel, Thanks for clearing that up :) |
Ping? Can this please go in? It's such a great improvement to user experience! I've seen too many novice users print a ton of output by accident and have IDLE hang as a result, losing their interactive session. This simple extension avoid those issues completely, while still allowing access to the output if needed. I'd even be willing to do any extra work required, such as testing on Windows, Linux and OSX. Just tell me what's holding this up! |
Could you please provide a patch which applies to default branch? There is other proposed solution for the problem of large output: bpo-1442493. |
Here's a completely re-written patch! The patch is against current 3.3 (changeset 360976a6d8b9), since that's what Terry requested recently on bpo-3068. It also applies cleanly to the current default branch (changeset 360976a6d8b9). This patch has cleaner, modern code, with doc-strings everywhere and informative comments where appropriate. It also uses "import tkinter as tk" as Terry recently requested on bpo-3068. Furthermore, I've added a very complete set of tests for the new extension, which tests everything I could think of and achieves 100% coverage (!) of Squeezer.py. These are modern tests which make extensive use of mocking via the awesome unittest.mock module. I've included extensive in-code comments with the tests. Hopefully these will be useful as a reference for writing additional tests for IDLE code (at least other extensions). Finally, this patch includes a minor change to ToolTip.py, adding the ability to specify the delay after which a tooltip is displayed (was hard-coded to 1.5 seconds). This change is required by the extension (I prefer that it uses tooltips with no delay). |
Expanded text still makes IDLE unresponsible. Try print('a'*10000000). I think it will be better to output first 100 lines and a button "More", pressing on which expands next 100 lines. |
During experiments I got following message on terminal: Exception in Tkinter callback
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 1482, in __call__
return self.func(*args)
File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 534, in callit
func(*args)
File "/home/serhiy/py/cpython/Lib/idlelib/ToolTip.py", line 44, in showtip
x = self.button.winfo_rootx() + 20
File "/home/serhiy/py/cpython/Lib/tkinter/__init__.py", line 845, in winfo_rootx
self.tk.call('winfo', 'rootx', self._w))
_tkinter.TclError: bad window path name ".3066068076.3066068332.text.3048812460" May be it is unrelated. |
Regarding the tooltip traceback, seems like that could be related. I added a tooltip to the "squeezed text" buttons, with no delay, so perhaps there's some kind of race condition? Could you try changing "delay=0" in the code to "delay=50" and see if the issue goes away? I would test this myself if you could specify how to reproduce that error. |
I'm not able to reproduce the problem after the first time (even with |
Indeed, expanding very long texts still degrades the performance of IDLE. But the user has to explicitly expand the text (by double-clicking the button) and can easily squeeze the text again. As for your suggestion to show just the first several lines and a "more..." button, that would be a significantly more complex solution. It is already easy to preview the squeezed text, either by launching an external viewer or by copying the text to the clipboard. Yes, a user could still get large amount of text in the shell by expanding large squeezed text. In other words, a user can still shoot himself in the foot; but now he'd have to purposefully aim the shotgun at his foot first. |
The test emits a lot of warnings. |
Serhiy, which warnings? Some of the tests use Tk GUI elements, so they include "requires('gui')". You need to run the tests with a proper environment so that these tests are run; otherwise you get a warning that the 'gui' resource in unavailable. |
See related bpo-6143 "IDLE - an extension to clear the shell window", where special support for Squeezer is required in that extension (patch included there). |
Mainly deprecation warnings about assertEquals(). Run
|
See msg212020 for a Python-style explanation of the utility of the Squeezer extension. |
Added screenshot of what working with the IDLE shell with the Squeezer extension looks like (on Windows). Note that the second squeezed text is the very long "Max recursion depth" exception traceback, which I manually squeezed after it was printed. |
New PR ready for review. I've updated the code for recent master and cleaned up the deprecation warnings from the tests. |
I'm back to working on this. I've made good progress: I'm nearly done with all of the changes suggested here and ready for another PR review. I'd like some opinions on a few things:
|
I've gone ahead and addressed all of the significant issues raised here:
I've also updated all of the tests accordingly and added a few. There a several tweaks to consider, including those mentioned in my previous message, plus colors and key bindings. This is now ready for another review! |
I partly answered questions already.
Converting extensions to features mostly removed the option to omit features.
I want to make revising the use of keys within output blocks a separate issue.
'a'*1000 currently wraps to 13 80-char lines. (This would change if we add horizontal scrollbar, as has been requested.) The viewer does not wrap. I think it should as there is now no way to see entire line. Or it needs a scrollbar. Viewer is modal, but does it need to be? |
Done.
Done.
Indeed.
Done.
I'm still not sure, that just leads to very large numbers, where it's hard to judge what is excessive, e.g., "is 100,000 chars too much"? With lines, I feel it is more obvious: "1,000 lines? That's way too much!"
Wrapping is the major cause of the text widget slowing down, which is why I've made the viewer support controlling the wrapping mode, and made Squeezer use no wrapping. I've now added a horizontal scrollbar, and also made the scrollbars in the viewer appear only when needed. Now, scrolling horizontally with very long lines is still slow, but at least just the viewer is affected.
No, good catch, changed to non-modal. |
The PR is ready for another review. ISTM it should be good to go, after have addressing all of the significant issues brought up in the discussion here. |
Tal, if you think this is ready, I would like to get this in the upcoming releases. I believe the deadline is midnight at the international dateline, which is noon UTC tomorrow, just over 9 hours from now. I decided that any suggestions I might have for the non-user-visible aspects of squeezer.py and test_squeezer.py can wait for later. The best review of user-visible aspects will come from using it. A second use of squeezer should be debugger's global and non-global('local') namespace displays. The intended format is one name-value pair per line. But values can be indefinitely large. For this, we could skip the context menu (there is not one now), use a fixed trigger of n characters, and have double-click display to a popup Squeezer View. I will come back to this in a couple of hours to see if you have responded. I would write and merge a separate expanded news entry for idlelib/NEWS.txt. |
Working on getting this in now. Just in time, it seems. |
This seems like it would need a "What's New" entry. How does this work with IDLE re. new features being backported? |
New changeset 604e7b9 by Tal Einat in branch 'master': |
New changeset 321f28c by Miss Islington (bot) in branch '3.7': |
New changeset 0b3e120 by Miss Islington (bot) in branch '3.6': |
New changeset dac712d by Terry Jan Reedy in branch 'master': |
New changeset ea718d3 by Terry Jan Reedy in branch 'master': |
New changeset 98c8236 by Miss Islington (bot) in branch '3.6': |
New changeset 92ad261 by Miss Islington (bot) in branch '3.7': |
New changeset 3637e68 by Miss Islington (bot) in branch '3.7': |
See my 3.6/3.7 patches for how I now handle new-in-maintenance-release user-visible features in What's New. Note that there are similar entries for Python at the bottom of the file. If I were not rushing, I would have mentioned user colors in text view. But that is minor and I will add one entry for colors and font sizes in both text and help views when done. |
New changeset fdcb5ae by Terry Jan Reedy in branch 'master': |
ISTM that this issue can finally be closed! Followup on some remaining minor points brought up here, such as colors and squeezing of multiple output lines printed separately, could be done in separate issues or discussed on idle-dev. |
Yes. Congratulations on your persistence. |
New changeset 68d6dc0 by Terry Jan Reedy in branch 'master': |
New changeset 8dccb00 by Miss Islington (bot) in branch '3.7': |
New changeset 69ab28d by Miss Islington (bot) in branch '3.6': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: