Skip to content

gh-42010: IDLE Editor Bottom Scroll Bar #1984

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from idlelib import query
from idlelib import replace
from idlelib import search
from idlelib.textview import AutoShowScrollbar
from idlelib.tree import wheel_event
from idlelib import window

Expand Down Expand Up @@ -68,6 +69,7 @@ class EditorWindow(object):

allow_code_context = True
allow_line_numbers = True
allow_hbar = True

def __init__(self, flist=None, filename=None, key=None, root=None):
# Delay import: runscript imports pyshell imports EditorWindow.
Expand Down Expand Up @@ -121,7 +123,6 @@ def __init__(self, flist=None, filename=None, key=None, root=None):

self.prompt_last_line = '' # Override in PyShell
self.text_frame = text_frame = Frame(top)
self.vbar = vbar = Scrollbar(text_frame, name='vbar')
width = idleConf.GetOption('main', 'EditorWindow', 'width', type='int')
text_options = {
'name': 'text',
Expand All @@ -135,6 +136,13 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
}
self.text = text = MultiCallCreator(Text)(text_frame, **text_options)
self.top.focused_widget = self.text
self.vbar = vbar = Scrollbar(text_frame, name='vbar',
takefocus=False,
command=self.handle_yview)
self.hbar = hbar = AutoShowScrollbar(text_frame, name="hbar",
orient="horizontal",
takefocus=False,
command=text.xview)

self.createmenubar()
self.apply_bindings()
Expand Down Expand Up @@ -209,9 +217,11 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
text_frame.pack(side=LEFT, fill=BOTH, expand=1)
text_frame.rowconfigure(1, weight=1)
text_frame.columnconfigure(1, weight=1)
vbar['command'] = self.handle_yview
vbar.grid(row=1, column=2, sticky=NSEW)
text['yscrollcommand'] = vbar.set
if self.allow_hbar:
hbar.grid(row=2, column=1, sticky="ew")
text['xscrollcommand'] = hbar.set
text['font'] = idleConf.GetFont(self.root, 'main', 'EditorWindow')
text.grid(row=1, column=1, sticky=NSEW)
text.focus_set()
Expand Down
4 changes: 2 additions & 2 deletions Lib/idlelib/idle_test/test_textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def test_ok(self):
view.destroy()


class AutoHideScrollbarTest(unittest.TestCase):
class AutoShowScrollbarTest(unittest.TestCase):
# Method set is tested in ScrollableTextFrameTest
def test_forbidden_geometry(self):
scroll = tv.AutoHideScrollbar(root)
scroll = tv.AutoShowScrollbar(root)
self.assertRaises(TclError, scroll.pack)
self.assertRaises(TclError, scroll.place)

Expand Down
1 change: 1 addition & 0 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ class PyShell(OutputWindow):
]

allow_line_numbers = False
allow_hbar = False

# New classes
from idlelib.history import History
Expand Down
6 changes: 3 additions & 3 deletions Lib/idlelib/textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from idlelib.colorizer import color_config


class AutoHideScrollbar(Scrollbar):
class AutoShowScrollbar(Scrollbar):
"""A scrollbar that is automatically hidden when not needed.

Only the grid geometry manager is supported.
Expand Down Expand Up @@ -53,15 +53,15 @@ def __init__(self, master, wrap=NONE, **kwargs):
self.grid_columnconfigure(0, weight=1)

# vertical scrollbar
self.yscroll = AutoHideScrollbar(self, orient=VERTICAL,
self.yscroll = AutoShowScrollbar(self, orient=VERTICAL,
takefocus=False,
command=text.yview)
self.yscroll.grid(row=0, column=1, sticky=NS)
text['yscrollcommand'] = self.yscroll.set

# horizontal scrollbar - only when wrap is set to NONE
if wrap == NONE:
self.xscroll = AutoHideScrollbar(self, orient=HORIZONTAL,
self.xscroll = AutoShowScrollbar(self, orient=HORIZONTAL,
takefocus=False,
command=text.xview)
self.xscroll.grid(row=1, column=0, sticky=EW)
Expand Down