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: New menu item for view options in array and dataframe editors #22061

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jitseniesen
Copy link
Member

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

This PR adds a new menu item Display options ... to the options menu of the array and dataframe editors. Clicking this menu item brings up a dialog window where the user can set float format, whether to use a background color and what coloring algorithm to use (the last option only appears for dataframe editors). The new menu item replaces the existing icons and menu items for setting these options.

The reason for this PR is that it is not clear what these options do and having a separate dialog window allows us to add more context. See issue #21824 for some discussion. I replaced the text Additional preferences for the menu item, which was suggested in that issue, because I thought we should remove the word "additional" as it is not clear in addition to what these preferences are.

Here is a video showing the new window:

varexp-editor-prefs.mp4

Issue(s) Resolved

Fixes #21824

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct:
Jitse Niesen

* Add new class PreferencesDialog in which the user can pick the format
  for floats and the options for the background color.
* Add an item to the hamburger menu in the dataframe editor which uses
  this dialog for setting the view options.
* Remove the old actions for these view options.
* Add and update tests.
* Update related doc strings in DataFrameModel.
* Add extra parameter to PreferencesDialog to determine whether it's
  setting view options for dataframe or array editor.
* Add item to hamburger menu in array editor which uses this dialog.
* Remove old actions for setting float format and toggling background.
@pep8speaks
Copy link

Hello @jitseniesen! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 1143:13: E722 do not use bare 'except'

Line 2282:13: E722 do not use bare 'except'

@ccordoba12 ccordoba12 modified the milestones: v6.0beta1, v6.0beta2 May 10, 2024
@ccordoba12 ccordoba12 modified the milestones: v6.0beta2, v6.0beta3 Jun 17, 2024
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jitseniesen for your work on this, it looks really cool!

If True, vary backgrond color depending on cell value
_format_spec : str
Format specification for floats
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
"""

If True, select background color by comparing cell value against
column maximum and minimum. Otherwise, use maximum and minimum of
the entire dataframe.
_format_spec : str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_format_spec : str
format_spec : str

Seems a typo?

Comment on lines +17 to +18
QDialog, QDialogButtonBox, QGroupBox, QLabel, QLineEdit, QRadioButton,
QVBoxLayout, QWidget)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QDialog, QDialogButtonBox, QGroupBox, QLabel, QLineEdit, QRadioButton,
QVBoxLayout, QWidget)
QDialog,
QDialogButtonBox,
QGroupBox,
QLabel,
QLineEdit,
QRadioButton,
QVBoxLayout,
QWidget
)

Let's use Black style of list import to avoid silly conflicts in the future.

QVBoxLayout, QWidget)

# Local imports
from spyder.config.base import _
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from spyder.config.base import _
from spyder.api.translations import _
from spyder.api.widgets.dialogs import SpyderDialogButtonBox
  • Better to use the API import for _.
  • The second import is needed below.

Comment on lines +66 to +69
self.format_input.setToolTip(_(
'Use same syntax as for built-in <tt>format()</tt> function. '
'Default is <tt>.6g</tt>.'
))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for this and most of the other tooltips you set in this dialog we could the new TipWidget in spyder.widgets.helperwidgets. That would make finding this additional help easier for users.

What do you think?

Comment on lines +115 to +116
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
self.buttons = SpyderDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel
)

@@ -56,6 +56,8 @@
from spyder.config.base import _
from spyder.plugins.variableexplorer.widgets.arrayeditor import get_idx_rect
from spyder.plugins.variableexplorer.widgets.basedialog import BaseDialog
from spyder.plugins.variableexplorer.widgets.preferences import (
PreferencesDialog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PreferencesDialog)
PreferencesDialog
)

@@ -40,23 +40,25 @@
from spyder.config.base import _
from spyder.config.manager import CONF
from spyder.plugins.variableexplorer.widgets.basedialog import BaseDialog
from spyder.plugins.variableexplorer.widgets.preferences import (
PreferencesDialog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PreferencesDialog)
PreferencesDialog
)

"""

from spyder.plugins.variableexplorer.widgets.preferences import (
PreferencesDialog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PreferencesDialog)
PreferencesDialog
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's not clear what some actions in the new Options menus of Variable Explorer editors do
3 participants