Skip to content
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

Add an option to configure scrollbar visibility #357

Merged
merged 1 commit into from
Sep 6, 2019
Merged
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
22 changes: 20 additions & 2 deletions qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, superQ
The text is written directly to the console.
""")

scrollbar_visibility = Bool(True, config=True,
help="""The visibility of the scrollar. If False then the scrollbar will be
invisible."""
)

font_family = Unicode(config=True,
help="""The font family to use for the console.
On OSX this defaults to Monaco, on Windows the default is
Expand Down Expand Up @@ -1131,12 +1136,18 @@ def _create_control(self):
layout.documentSizeChanged.disconnect()
layout.documentSizeChanged.connect(self._adjust_scrollbars)

# Configure the scrollbar policy
if self.scrollbar_visibility:
scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOn
else :
scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOff

# Configure the control.
control.setAttribute(QtCore.Qt.WA_InputMethodEnabled, True)
control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
control.setReadOnly(True)
control.setUndoRedoEnabled(False)
control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
control.setVerticalScrollBarPolicy(scrollbar_policy)
return control

def _create_page_control(self):
Expand All @@ -1153,7 +1164,14 @@ def _create_page_control(self):
viewport.installEventFilter(self)
control.setReadOnly(True)
control.setUndoRedoEnabled(False)
control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)

# Configure the scrollbar policy
if self.scrollbar_visibility:
scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOn
else :
scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOff

control.setVerticalScrollBarPolicy(scrollbar_policy)
return control

def _event_filter_console_keypress(self, event):
Expand Down