简体   繁体   中英

How do I adjust Python IDLE Shell settings so that the next line of code I type stays vertically in the center of the shell at all times?

So there is probably a real basic solution for this but I obviously don't know what it is. When I'm writing code in IDLE window, eventually I get to the bottom of the window and then each new line of code I write is at the bottom of the window, which is annoying to read as I'm continually staring at the bottom of my screen as I write each new line of code. Is there a way to get the IDLE shell to jump back to the top of the window once I reach the bottom?

Or another way to look at it would be to constantly have roughly 20 or so empty lines present after the new line of code I'm writing, so that my code never gets to the bottom of the window and thus each new line of code I write is always centered in the window.

I know I could simply minimize the window itself and position it so that the bottom of the window is in the center of my screen (vertically) but that's not really a solution as then I'm dealing with this window sliver that I'll have to maximize every time I want to review my code in it's whole.

Thanks!

The behavior of IDLE's Shell intentionally mimic the behavior interactive Python in command-line console and terminal programs. The latter typically default to 24 lines because that is what physical glass terminals usually had. On modern high-definition monitors, 'normal' size fonts allow more lines on a screen. If a 24-line window is put with its top at the top of the screen, the bottom line is at the middle of the screen.

IDLE defaults to 4O so one can seen more text at one time. You could customize this to fewer lines, but this would reduce the side of editor windows also. You could instead resize just the Shell with your mouse, and then move it up to the top of the screen. When you want to see more, you can use Zoom Height on the options menu. If you do not like the default hot key you can change it.

When Shell starts, there is a blank space beneath the input prompt. This space is not filled with blank lines. If it were, you could move he cursor down. Once the window is filled with lines of whatever length, the only way to restore the blank space is to delete all but the last N lines. https://bugs.python.org/issue6143 is about clearing all or possibly just some of the shell output.

PS. The Shell windows uses one tkinter Text widget for both read-only history and read-write code entry. I have thought about using two text boxes instead. This might allow keeping entry permanently above the output instead of below, but it is not clear if you would like this any better.

If I were to do make this split, I might add a configurable minimum size for the entry box, so that entry would always start k lines above the bottom. But this is speculative and still in the design stage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM