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: Fix issues with scrolling in dataframe editor (Variable Explorer) #21913

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

jitseniesen
Copy link
Member

@jitseniesen jitseniesen commented Mar 20, 2024

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) N/A

This PR fixes two scrolling-related bugs in the dataframe editor.

Firstly, after my PR implementing Refresh in the master branch, the scrollbars were no longer visible. To fix this, I changed it so that the view (the UI element) is created only once instead of every time that the data is refreshed. As before a new model (which exposes the data) is created every time that the data is refreshed.

Secondly, a bug already present in Spyder 5 caused the editor to jump back if you sorted the last column of a large data frame, as well as some more odd behaviour. The fix for this is to set the number of rows and columns loaded in the DataFrameHeaderModel using the information in the corresponding DataFrameModel. This is the bug reported in issue #21627.

This PR also add regression test for both these bugs.

Issue(s) Resolved

Fixes #21627

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

@jitseniesen jitseniesen changed the title PR: Fix issues withg Dataframe scroll PR: Fix issues with scrolling in dataframe editor Mar 20, 2024
@jitseniesen jitseniesen self-assigned this Mar 20, 2024
@jitseniesen jitseniesen added this to the v6.0beta1 milestone Mar 20, 2024
Change DataFrameEditor so that it creates the DataFrameView in
setup_ui() and the DataFrameModel in set_data_and_check(). This
means that the DataFrameView is created only once, but the
DataFrameModel is created every time the data is refreshed. Before,
a new DataFrameView and a new DataFrameModel were created every time
the data was refreshed.

This fixes a bug where the scroll bars were not visible if the data
frame too big. This commit also adds a test for this.
When setting the number of rows and columns loaded in the
DataFrameHeaderModel, use the information in the corresponding
DataFrameModel. This allows for the possibility that rows and
columns were loaded before the DataFrameHeaderModel was created.

This fixes a bug where a data frame editor with a large data
frame was opened, so that not all columns are initially loaded.
Then if you scroll to the last column and sort that column, a new
DataFrameHeaderModel was created which used the wrong value of
cols_loaded, causing the editor to scroll back. Also add a
regression test for the bug.
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.

Looks good to me, thanks @jitseniesen!

df = DataFrame(numpy.zeros((100, 100)))
editor = DataFrameEditor()
editor.setup_and_check(df)
with qtbot.waitExposed(editor):
Copy link
Member

Choose a reason for hiding this comment

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

This is really nice! I didn't know about this functionality in qtbot.

@ccordoba12 ccordoba12 modified the milestones: v6.0beta1, v6.0alpha5 Mar 29, 2024
@ccordoba12 ccordoba12 merged commit 5ce3ab5 into spyder-ide:master Mar 29, 2024
14 checks passed
@ccordoba12 ccordoba12 changed the title PR: Fix issues with scrolling in dataframe editor PR: Fix issues with scrolling in dataframe editor (Variable Explorer) Mar 29, 2024
@jitseniesen jitseniesen deleted the dataframe-scroll branch September 16, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants