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

PR: Improve Variable Explorer UX #20868

Merged
merged 41 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
60d290e
first changes in variable explorer
jsbautista Apr 24, 2023
87f5f65
changes in variable explorer
jsbautista Apr 24, 2023
e141af6
Merge branch 'master' into VariableExplorerIssues
jsbautista Apr 24, 2023
48eca80
Apply suggestions
jsbautista May 4, 2023
fd97307
Merge branch 'VariableExplorerIssues' of https://github.com/jsbautist…
jsbautista May 4, 2023
a92d52a
Apply suggestions
jsbautista May 4, 2023
bd90a85
Apply suggestions
jsbautista May 8, 2023
191afe1
Merge branch 'master' into VariableExplorerIssues
jsbautista May 8, 2023
4e3ef83
Apply suggestions
jsbautista May 8, 2023
644d55b
Merge branch 'VariableExplorerIssues' of https://github.com/jsbautist…
jsbautista May 8, 2023
c04755e
Apply suggestions
jsbautista May 8, 2023
17b630a
Apply suggestions
jsbautista May 15, 2023
d61b818
Apply suggestions
jsbautista May 15, 2023
ee61c05
Apply suggestions
jsbautista May 18, 2023
5446cb8
Merge branch 'master' into VariableExplorerIssues
jsbautista May 18, 2023
111a90c
Update spyder/plugins/variableexplorer/widgets/main_widget.py
jsbautista May 29, 2023
06b6d2e
Merge branch 'master' into VariableExplorerIssues
jsbautista May 29, 2023
4bb6b65
Apply suggestions from code review
jsbautista Jun 5, 2023
f146d1c
Apply suggestions
jsbautista Jun 6, 2023
f6ca198
Merge branch 'master' into VariableExplorerIssues
jsbautista Jun 13, 2023
b1fba82
git subrepo pull --remote=https://github.com/jsbautista/spyder-kernel…
jsbautista Jun 13, 2023
4028882
Merge branch 'master' into VariableExplorerIssues
jsbautista Jun 19, 2023
d669a1a
git subrepo pull --remote=https://github.com/jsbautista/spyder-kernel…
jsbautista Jun 19, 2023
d71a5a1
Merge branch 'VariableExplorerIssues' of https://github.com/jsbautist…
jsbautista Jun 19, 2023
429c61a
Apply suggestions
jsbautista Jun 26, 2023
2f08bb1
Merge branch 'master' into VariableExplorerIssues
jsbautista Jun 26, 2023
e85910a
Merge branch 'master' into VariableExplorerIssues
jsbautista Jul 4, 2023
0d2e4ca
Merge branch 'master' into VariableExplorerIssues
jsbautista Jul 7, 2023
079132d
Apply suggestions
jsbautista Jul 10, 2023
cb27172
Merge branch 'VariableExplorerIssues' of https://github.com/jsbautist…
jsbautista Jul 10, 2023
8054316
Apply suggestions
jsbautista Jul 10, 2023
ea6243a
Apply suggestions
jsbautista Jul 10, 2023
b005727
Apply suggestions
jsbautista Jul 10, 2023
c1703d0
Apply suggestions
jsbautista Jul 10, 2023
cd1f439
Apply suggestions
jsbautista Jul 10, 2023
4952a49
Apply suggestions
jsbautista Jul 10, 2023
ae04a3c
Update spyder/widgets/collectionseditor.py
jsbautista Jul 12, 2023
dd82da9
git subrepo pull --remote=https://github.com/spyder-ide/spyder-kernel…
dalthviz Jul 12, 2023
4c68a79
Apply suggestions from code review
dalthviz Jul 13, 2023
7f930d7
Create private API section
dalthviz Jul 13, 2023
a9e895b
Update maininterpreter open preferences logic
dalthviz Jul 13, 2023
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
2 changes: 1 addition & 1 deletion external-deps/spyder-kernels/.gitrepo

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions external-deps/spyder-kernels/spyder_kernels/utils/nsview.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
'truncate': True,
'minmax': False,
'show_callable_attributes': True,
'show_special_attributes': False
'show_special_attributes': False,
'filter_on': True
}),
('debugger',
{
Expand Down
3 changes: 2 additions & 1 deletion spyder/plugins/ipythonconsole/comms/tests/test_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def kernel(request):
'False_',
'True_'
],
'minmax': False}
'minmax': False,
'filter_on': True}

# Teardown
def reset_kernel():
Expand Down
3 changes: 2 additions & 1 deletion spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,8 @@ def test_pdb_comprehension_namespace(ipyconsole, qtbot, tmpdir):
'excluded_names': [],
'minmax': False,
'show_callable_attributes': True,
'show_special_attributes': False}
'show_special_attributes': False,
'filter_on': True}

shell.call_kernel(
interrupt=True
Expand Down
13 changes: 9 additions & 4 deletions spyder/plugins/variableexplorer/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
from spyder.config.base import _
from spyder.api.preferences import PluginConfigPage


class VariableExplorerConfigPage(PluginConfigPage):

def setup_page(self):
filter_group = QGroupBox(_("Filter"))
filter_data = [
('exclude_private', _("Exclude private references")),
('exclude_capitalized', _("Exclude capitalized references")),
('exclude_uppercase', _("Exclude all-uppercase references")),
('exclude_unsupported', _("Exclude unsupported data types")),
('exclude_private',
_("Exclude private references")),
('exclude_capitalized',
_("Exclude capitalized references")),
('exclude_uppercase',
_("Exclude all-uppercase references")),
('exclude_unsupported',
_("Exclude unsupported data types")),
('exclude_callables_and_modules',
_("Exclude callables and modules"))
]
Expand Down
14 changes: 13 additions & 1 deletion spyder/plugins/variableexplorer/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ def get_icon(self):
return self.create_icon('dictedit')

def on_initialize(self):
pass
widget = self.get_widget()
widget.sig_open_preferences_requested.connect(
self._open_preferences
)

def _open_preferences(self):
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
"""Open the Preferences dialog in the Variable Explorer section."""
self._main.show_preferences()
preferences = self._main.preferences
container = preferences.get_container()
dlg = container.dialog
index = dlg.get_index_by_name(self.NAME)
dlg.set_current_index(index)
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

@on_plugin_available(plugin=Plugins.Preferences)
def on_preferences_available(self):
Expand Down
96 changes: 73 additions & 23 deletions spyder/plugins/variableexplorer/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# Third party imports
from qtpy.QtCore import QTimer, Slot
from qtpy.QtCore import QTimer, Slot, Signal
from qtpy.QtWidgets import QAction

# Local imports
Expand All @@ -18,6 +18,7 @@
from spyder.api.shellconnect.main_widget import ShellConnectMainWidget
from spyder.plugins.variableexplorer.widgets.namespacebrowser import (
NamespaceBrowser)
from spyder.utils.icon_manager import ima
from spyder.utils.programs import is_module_installed


Expand All @@ -41,11 +42,17 @@ class VariableExplorerWidgetActions:
ToggleExcludeCallablesAndModules = (
'toggle_exclude_callables_and_modules_action')
ToggleMinMax = 'toggle_minmax_action'
ToggleFilter = 'toggle_filter_variable_action'

# Resize
ResizeRowsAction = 'resize_rows_action'
ResizeColumnsAction = 'resize_columns_action'


class VariableExplorerWidgetOptionsMenuSections:
Display = 'excludes_section'
Highlight = 'highlight_section'
Highlight = 'highlight_section'
Resize = 'resize_section'


class VariableExplorerWidgetMainToolBarSections:
Expand All @@ -58,8 +65,6 @@ class VariableExplorerWidgetMenus:


class VariableExplorerContextMenuActions:
ResizeRowsAction = 'resize_rows_action'
ResizeColumnsAction = 'resize_columns_action'
PasteAction = 'paste_action'
CopyAction = 'copy'
EditAction = 'edit_action'
Expand All @@ -72,13 +77,14 @@ class VariableExplorerContextMenuActions:
RenameAction = 'rename_action'
DuplicateAction = 'duplicate_action'
ViewAction = 'view_action'
EditFiltersAction = 'edit_filters_action'


class VariableExplorerContextMenuSections:
Edit = 'edit_section'
Insert = 'insert_section'
View = 'view_section'
Resize = 'resize_section'
Filter = 'Filter_section'


# =============================================================================
Expand All @@ -94,37 +100,45 @@ class VariableExplorerWidget(ShellConnectMainWidget):
INITIAL_FREE_MEMORY_TIME_TRIGGER = 60 * 1000 # ms
SECONDARY_FREE_MEMORY_TIME_TRIGGER = 180 * 1000 # ms

sig_open_preferences_requested = Signal()
"""
Signal to open the variable explorer preferences.
"""

def __init__(self, name=None, plugin=None, parent=None):
super().__init__(name, plugin, parent)


# Widgets
self.context_menu = None
self.empty_context_menu = None

self.filter_button = None

# ---- PluginMainWidget API
# ------------------------------------------------------------------------
def get_title(self):
return _('Variable Explorer')

def setup(self):
# ---- Options menu actions
exclude_private_action = self.create_action(
self.exclude_private_action = self.create_action(
VariableExplorerWidgetActions.ToggleExcludePrivate,
text=_("Exclude private variables"),
tip=_("Exclude variables that start with an underscore"),
toggled=True,
option='exclude_private',
)

exclude_uppercase_action = self.create_action(
self.exclude_uppercase_action = self.create_action(
VariableExplorerWidgetActions.ToggleExcludeUpperCase,
text=_("Exclude all-uppercase variables"),
tip=_("Exclude variables whose name is uppercase"),
toggled=True,
option='exclude_uppercase',
)

exclude_capitalized_action = self.create_action(
self.exclude_capitalized_action = self.create_action(
VariableExplorerWidgetActions.ToggleExcludeCapitalized,
text=_("Exclude capitalized variables"),
tip=_("Exclude variables whose name starts with a capital "
Expand All @@ -133,7 +147,7 @@ def setup(self):
option='exclude_capitalized',
)

exclude_unsupported_action = self.create_action(
self.exclude_unsupported_action = self.create_action(
VariableExplorerWidgetActions.ToggleExcludeUnsupported,
text=_("Exclude unsupported data types"),
tip=_("Exclude references to data types that don't have "
Expand All @@ -142,7 +156,7 @@ def setup(self):
option='exclude_unsupported',
)

exclude_callables_and_modules_action = self.create_action(
self.exclude_callables_and_modules_action = self.create_action(
VariableExplorerWidgetActions.ToggleExcludeCallablesAndModules,
text=_("Exclude callables and modules"),
tip=_("Exclude references to functions, modules and "
Expand Down Expand Up @@ -204,16 +218,25 @@ def setup(self):
register_shortcut=True,
)

self.filter_button = self.create_action(
jsbautista marked this conversation as resolved.
Show resolved Hide resolved
VariableExplorerWidgetActions.ToggleFilter,
text="",
icon=ima.icon('filter'),
toggled=self._enable_filter_actions,
option='filter_on',
tip=_("Filter variables")
)
self.filter_button.setCheckable(True)
# ---- Context menu actions
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
resize_rows_action = self.create_action(
VariableExplorerContextMenuActions.ResizeRowsAction,
VariableExplorerWidgetActions.ResizeRowsAction,
text=_("Resize rows to contents"),
icon=self.create_icon('collapse_row'),
triggered=self.resize_rows
)

resize_columns_action = self.create_action(
VariableExplorerContextMenuActions.ResizeColumnsAction,
VariableExplorerWidgetActions.ResizeColumnsAction,
_("Resize columns to contents"),
icon=self.create_icon('collapse_column'),
triggered=self.resize_columns
Expand Down Expand Up @@ -279,6 +302,13 @@ def setup(self):
triggered=self.insert_item
)

self.edit_filters = self.create_action(
VariableExplorerContextMenuActions.EditFiltersAction,
_("Edit filters"),
icon=self.create_icon('filter'),
triggered=self.sig_open_preferences_requested
)

self.remove_action = self.create_action(
VariableExplorerContextMenuActions.RemoveAction,
_("Remove"),
Expand Down Expand Up @@ -309,20 +339,33 @@ def setup(self):

# Options menu
options_menu = self.get_options_menu()
for item in [exclude_private_action, exclude_uppercase_action,
exclude_capitalized_action, exclude_unsupported_action,
exclude_callables_and_modules_action,
for item in [self.exclude_private_action,
self.exclude_uppercase_action,
self.exclude_capitalized_action,
self.exclude_unsupported_action,
self.exclude_callables_and_modules_action,
self.show_minmax_action]:
self.add_item_to_menu(
item,
menu=options_menu,
section=VariableExplorerWidgetOptionsMenuSections.Display,
)

self._enable_filter_actions(self.get_conf('filter_on'))

# Resize
for item in [resize_rows_action, resize_columns_action]:
self.add_item_to_menu(
item,
menu=options_menu,
section=VariableExplorerWidgetOptionsMenuSections.Resize,
)

# Main toolbar
main_toolbar = self.get_main_toolbar()
for item in [import_data_action, save_action, save_as_action,
reset_namespace_action, search_action, refresh_action]:
reset_namespace_action, search_action, refresh_action,
self.filter_button]:
self.add_item_to_toolbar(
item,
toolbar=main_toolbar,
Expand All @@ -349,19 +392,19 @@ def setup(self):
section=VariableExplorerContextMenuSections.Insert,
)

for item in [self.view_action, self.plot_action, self.hist_action,
self.imshow_action, self.show_minmax_action]:
for item in [self.edit_filters]:
self.add_item_to_menu(
item,
menu=self.context_menu,
section=VariableExplorerContextMenuSections.View,
section=VariableExplorerContextMenuSections.Filter,
)

for item in [resize_rows_action, resize_columns_action]:

for item in [self.view_action, self.plot_action, self.hist_action,
self.imshow_action]:
self.add_item_to_menu(
item,
menu=self.context_menu,
section=VariableExplorerContextMenuSections.Resize,
section=VariableExplorerContextMenuSections.View,
)

# ---- Context menu when the variable explorer is empty
Expand Down Expand Up @@ -557,7 +600,6 @@ def _set_actions_and_menus(self, nsb):
editor.save_array_action = self.save_array_action
editor.insert_action = self.insert_action
editor.remove_action = self.remove_action
editor.minmax_action = self.show_minmax_action
editor.rename_action = self.rename_action
editor.duplicate_action = self.duplicate_action
editor.view_action = self.view_action
Expand All @@ -571,3 +613,11 @@ def _set_actions_and_menus(self, nsb):
# several places in CollectionsEditor.
editor.insert_action_above = QAction()
editor.insert_action_below = QAction()

def _enable_filter_actions(self, value):
"""Handle the change of the filter state."""
self.exclude_private_action.setEnabled(value)
self.exclude_uppercase_action.setEnabled(value)
self.exclude_capitalized_action.setEnabled(value)
self.exclude_unsupported_action.setEnabled(value)
self.exclude_callables_and_modules_action.setEnabled(value)
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading