diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 04c786dc5234c2..8563ec7f8879dc 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -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 @@ -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. @@ -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', @@ -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() @@ -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() diff --git a/Lib/idlelib/idle_test/test_textview.py b/Lib/idlelib/idle_test/test_textview.py index 7189378ab3dd61..6df5f2ed45d572 100644 --- a/Lib/idlelib/idle_test/test_textview.py +++ b/Lib/idlelib/idle_test/test_textview.py @@ -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) diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index d5b310ffd7a9be..c2928db8f92827 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -856,6 +856,7 @@ class PyShell(OutputWindow): ] allow_line_numbers = False + allow_hbar = False # New classes from idlelib.history import History diff --git a/Lib/idlelib/textview.py b/Lib/idlelib/textview.py index 808a2aefab4f71..b519d7ba39857e 100644 --- a/Lib/idlelib/textview.py +++ b/Lib/idlelib/textview.py @@ -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. @@ -53,7 +53,7 @@ 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) @@ -61,7 +61,7 @@ def __init__(self, master, wrap=NONE, **kwargs): # 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)