This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add a "copy value to clipboard" option to the debugger
Type: enhancement Stage:
Components: IDLE Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: THRlWiTi, terry.reedy
Priority: normal Keywords:

Created on 2015-05-01 11:20 by THRlWiTi, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg242303 - (view) Author: Thrlwiti (THRlWiTi) * Date: 2015-05-01 11:20
I suggest adding a "Copy variable to clipboard" menu option to the edit menu of IDLE.

Sometimes I need to copy a variable to clipboard, but because the variable is so long, printing it in the IDLE window makes IDLE sluggish and then selecting and copying the printed value becomes a little cumbersome.

Of-coarse as it is suggested in [1], I can do copy the variable `v` using the following commands:

from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(str(v))
r.destroy()

but I think it's too much and it would be nice to have such menu option that after clicking on it a dialog box appears asking for variable name and after entering the name causes the str content of the variable to be copied to the clipboard.

[1]: https://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python
msg242364 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-05-02 01:25
As presented, this idea seems out of scope for Idle.  First, Idle is concerned with editing code, submitting it for execution, and displaying stdout and seterr output from the execution.  Idle normally knows nothing about name bindings created by user code in the user process. The code for menu commands is executed in the Idle process.  The code you displayed would have to be executed in the user process as part of user code.

Second, your request is for a very specific personal need. Running 
for i in range(1000): print('a'*100)
in 3.4.3 does not make Shell sluggish for me.  How much output, on what system, with what version, is a problem for you?

However, selecting a 1000 line block -- which is at least as likely to be output (as above) as an output representation -- is not pleasant.  A new Select Block option, active in Shell, would be generally useful.  The selected block could then be copied.  Deletion is not currently possible, but I might like to change that too. 


The debugger is an exception to Idle's normal ignorance of user code global and local namespaces.  The debugger window (which needs upgrading) can display names and object representations of both namespaces.  I do not know what it currently does with long representations (say 1000 chars or more), but they  are clearly problematical and might best be truncated if not already.  Once the debugger has already pulled a string representation into the Idle process. reusing the existing Copy (to clipboard) function should be fairly easy.
msg336442 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-02-24 07:03
The squeezer feature added last summer can be used to copy large output in Shell to the clipboard.  '>>> [None]*10000' results in a squeezer label representing 750 wrapped lines.  Note that pasting into a new editor disables it for awhile.  (Editor does not wrap).  Pasting into command prompt is not good either.  Notepad++ handles the 60000 char line pretty well.

I am not sure what I was thinking about a block copy in Shell.  If a block is selected, it is easily copied.

My thinking now is that large output in the debugger should be squeezed, at a much lower threashhold than in Shell.  It is designed for values of, say, 40 chars or less.  'Large' values could then be copied to clipboard or displayed in a separate viewer.
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68278
2019-02-24 07:03:58terry.reedysetmessages: + msg336442
versions: + Python 3.8, - Python 3.4
2015-05-02 01:25:38terry.reedysettitle: Add a "copy vale to clipboard" option to the debugger -> Add a "copy value to clipboard" option to the debugger
2015-05-02 01:25:20terry.reedysetnosy: + terry.reedy

messages: + msg242364
title: Add a "copy variable to clipboard" option to the edit menu -> Add a "copy vale to clipboard" option to the debugger
2015-05-01 11:20:48THRlWiTicreate