Is there a horizontal scroll bar in python's idle?

11,957

Solution 1

Horizontal Scroll Bars for IDLE

from http://code.activestate.com/lists/python-list/26878/ (not my code, found it on this site) It is dated Wed, 08 Mar 2000

Works for Python 2.6 but I can't get to work in 2.7. I get an error saying that the file is open some where. For me, the file he is talking about is located in:C:\Python27\ArcGIS10.1\Lib\idlelib It will be different if you do not have the ArcMap program which comes with python and installs it for you.

I finally got around to adding horizontal scroll bars to the IDLE editor window to help when you get those LONG lines of code. They changes are rather mionor (4 new lines of code) and were made in the EditorWindow.py module. To make the changes in IDLE, open EditorWindow.py and perform a search for 'vbar' which is in the EditorWindow class, __init__ method. Add those lines that have ### appended to them and VOILA you have it. Unfortunately, the scrollbar appears BELOW the row and column information in IDLE 0.5 (sigh).

    self.vbar = vbar = Scrollbar(top, name='vbar')
    self.hbar = hbar = Scrollbar(top, orient=HORIZONTAL, name='hbar') ###
    ...
    vbar['command'] = text.yview
    vbar.pack(side=RIGHT, fill=Y)
    hbar['command'] = text.xview        ###
    hbar.pack(side=BOTTOM, fill=X)      ###

    text['yscrollcommand'] = vbar.set
    text['xscrollcommand'] = hbar.set   ###

Hope this is helpful.

Jonathan Polley

jwpolley at collins.rockwell.com

Solution 2

No. IDLE does not have horizontal scrollbars for two reasons:

  1. Its text editor has few features.
  2. You shouldn't be writing long lines of code. See the Maximum Line Length section of the PEP 8 Style Guide for Python Code

Solution 3

I'm using IDLE 2.7.3, Windows 7, and I can scroll horizontally by holding down the center mouse button/scroll wheel, and "dragging" around the cursor like that.

Solution 4

I may not be a Python expert/guru yet but this question is a user-experience / usability question more than anything. Some might say "Yeah, PEP 8 style guide... blah blah blah" but if I have the IDLE window a certain size (let's say small width), there's no reason I as a user shouldn't be able to scroll. It's simply poor user-experience as a result of poor design.

Solution 5

No, the text scrolls horizontally based on where the insertion point or selection is.

Share:
11,957
marl
Author by

marl

Updated on June 15, 2022

Comments

  • marl
    marl almost 2 years

    I am using IDLE to learn Python 2.7 on Windows 7.

    The Vertical scroll bar works fine but I cannot find
    a way to activate the Horizontal scroll bar.

    Is there a horizontal scroll bar in Python's IDLE?

    Thanks

  • marl
    marl about 12 years
    Good to know the about the style guide and the recommendation.
  • marl
    marl about 12 years
    I was trying to fit both brower and IDLE on same screen to type in code from tutorials. Find typing works better for learning purposes than cut and paste. Thanks for your advice
  • marl
    marl about 12 years
    Ok, so I should use cursor, home and end keys to move horizontally?
  • kindall
    kindall about 12 years
    Yes, or you can use the mouse by dragging. And of course you can just make the window wider.
  • ysap
    ysap almost 10 years
    Works like a charm in Python 3.4.1!
  • jpe
    jpe about 5 years
    I've added a version for Pytrhon 3.6: stackoverflow.com/a/54755273/1264516
  • boboquack
    boboquack about 4 years
    For Python 3.8.0, you now need to change the hbar.pack(side=BOTTOM, fill=X) line to hbar.grid(row=2, column=1, sticky=NSEW)
  • uzumaki
    uzumaki about 3 years
    Sometimes people just don't want IDLE to use up 50+% of screen real estate.