Skip to content

Commit

Permalink
Debugger: Improve UX of its breakpoints table
Browse files Browse the repository at this point in the history
- Remove min width and allow to collapse it. That should fix and error
when snapping the main window on Linux.
- Fix error in Python 3.10+ when setting the initial width for it.
  • Loading branch information
ccordoba12 committed Jun 12, 2024
1 parent c8f01e2 commit ab9d4af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions spyder/plugins/debugger/widgets/breakpoint_table_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class BreakpointTableView(QTableView, SpyderWidgetMixin):
"""

# Constants
MIN_WIDTH = 300
MIN_INITIAL_WIDTH = 300

# Signals
sig_clear_all_breakpoints_requested = Signal()
Expand Down Expand Up @@ -194,7 +194,6 @@ def __init__(self, parent, data):
self._adjust_columns()
self.horizontalHeader().setStretchLastSection(True)
self.verticalHeader().hide()
self.setMinimumWidth(self.MIN_WIDTH)

# Attributes
self._update_when_shown = True
Expand Down
14 changes: 8 additions & 6 deletions spyder/plugins/debugger/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(self, name=None, plugin=None, parent=None):
self.splitter.addWidget(self._stack)
self.splitter.addWidget(self.breakpoints_table)
self.splitter.setContentsMargins(0, 0, 0, 0)
self.splitter.setChildrenCollapsible(False)
self.splitter.setChildrenCollapsible(True)

# This is necessary so that the border radius is maintained when
# showing/hiding the breakpoints table
Expand Down Expand Up @@ -456,11 +456,13 @@ def on_breakpoints_table_option_update(self, value):
if value:
self.breakpoints_table.show()
action.setToolTip(_("Hide breakpoints"))
action.setText(_("Hide breakpoints"))
self._update_stylesheet(is_table_shown=True)
self._stack.setMinimumWidth(450)
else:
self.breakpoints_table.hide()
action.setToolTip(_("Show breakpoints"))
action.setText(_("Show breakpoints"))
self._update_stylesheet(is_table_shown=False)
self._stack.setMinimumWidth(100)

Expand Down Expand Up @@ -724,17 +726,17 @@ def showEvent(self, event):
def _update_splitter_widths(self, base_width):
"""
Update the splitter widths to provide the breakpoints table with a
fixed minimum width.
reasonable initial width.
Parameters
----------
base_width: int
The available splitter width.
The available widget width.
"""
if (base_width / 3) > self.breakpoints_table.MIN_WIDTH:
table_width = base_width / 3
if (base_width // 3) > self.breakpoints_table.MIN_INITIAL_WIDTH:
table_width = base_width // 3
else:
table_width = self.breakpoints_table.MIN_WIDTH
table_width = self.breakpoints_table.MIN_INITIAL_WIDTH

if base_width - table_width > 0:
self.splitter.setSizes([base_width - table_width, table_width])
Expand Down

0 comments on commit ab9d4af

Please sign in to comment.