-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Conversation
* 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.
Hello @jitseniesen! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
There was a problem hiding this 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 | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
""" | |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_format_spec : str | |
format_spec : str |
Seems a typo?
QDialog, QDialogButtonBox, QGroupBox, QLabel, QLineEdit, QRadioButton, | ||
QVBoxLayout, QWidget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
self.format_input.setToolTip(_( | ||
'Use same syntax as for built-in <tt>format()</tt> function. ' | ||
'Default is <tt>.6g</tt>.' | ||
)) |
There was a problem hiding this comment.
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?
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | | ||
QDialogButtonBox.Cancel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreferencesDialog) | |
PreferencesDialog | |
) |
""" | ||
|
||
from spyder.plugins.variableexplorer.widgets.preferences import ( | ||
PreferencesDialog) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreferencesDialog) | |
PreferencesDialog | |
) |
Description of Changes
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