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: Restore buttons that control the debugger to the main toolbar #22702

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

Conversation

ccordoba12
Copy link
Member

@ccordoba12 ccordoba12 commented Oct 21, 2024

Description of Changes

  • That's necessary because many people are accustomed to the Spyder 5 workflow, where they could control the debugger and see the Variable Explorer and IPython console at the same time.
  • Those buttons will be placed next to the current ones in the Debug toolbar, but they'll be shown only if there's an active debugging session in the current console.
  • Changes to the Toolbar plugin:
    • Declare a default order for toolbars in our config system.
    • If a toolbar is added or removed, toolbars will be reordered with the default order and the Working Directory will be placed to the right of all others. That's because it's not easy to visually see where that toolbar ends, so it's better to not place other toolbars to its right.
    • Fix loading last visible toolbars.
    • Rename/improve a couple of methods for clarity.
  • Changes to the Run plugin:
    • Allow to place items in toolbars using the full Toolbar API. That's necessary to place the debug file/cell/selection buttons before the ones that control the debugger.
  • API changes:
    • Add a new signal to SpyderToolbar to inform when it's rendered. That's necessary to get the widgets corresponding to the control debugger actions in the Debug toolbar, so we can hide/show them.

Visual changes

New buttons shown when a debugging session is started and hidden when it's stopped

control-debugger-buttons-show-and-hide

Issue(s) Resolved

Fixes #22434

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:

@ccordoba12
Copy link
Member Author

@dalthviz, could you manually check that the following things are working for you? Thanks!

  • The Control debugger toolbar is hidden for you when starting Spyder from this PR.
  • When enabled, it should be shown next to the Debug toolbar.
  • Change toolbars position, close and open Spyder and check the order is restored as expected.
  • Move a toolbar to the right of the Working Directory, close and open Spyder, and check the toolbar is moved to the left of it. That means the Working Directory will always be shown to the right of all other toolbars.

@ccordoba12 ccordoba12 force-pushed the issue-22434 branch 2 times, most recently from c6a7fab to d86d1c8 Compare October 21, 2024 18:52
@ccordoba12
Copy link
Member Author

ccordoba12 commented Oct 21, 2024

@dalthviz, in my last commit I also added some tests to cover the new functionality of the Toolbar plugin.

@dalthviz
Copy link
Member

Gave this a manual check and seems like the elements described above are working 👍 However, with the changes here, now is not possible to fully save toolbars state. So things like having more than one row of toolbars will not be possible, so something like:

image

Will not persist between sessions

That way it'll be easier to tell them apart.
- That's because not all toolbars are created with the
create_application_toolbar method.
- Also, remove repeated code between create and add app toolbars.
We'll need this to interate over the toolbars by id in the plugin
We were not correctly loading toolbars that are not visible.
- That restores the buttons available in Spyder 5, which was requested
by users.
- The toolbar is not visible by default to avoid showing repeated
functionality in the Debugger plugin and main toolbar.
Instead, add all its buttons to the Debug toolbar
Those buttons will be visible only if there's a debugging session active
in the current console.
@ccordoba12
Copy link
Member Author

ccordoba12 commented Oct 25, 2024

Thanks @dalthviz for the review!

Gave this a manual check and seems like the elements described above are working 👍 However, with the changes here, now is not possible to fully save toolbars state.

This should be fixed now, so please check again.

Also, I changed the implementation according to the UX team feedback. Now the buttons that control the debugger are shown in/hidden from the Debug toolbar when a debugging session is started/stopped (see the OP), or if the current console is in a debugging session or not. That avoids a serious issue with my previous approach: users would need to know that a new toolbar is available and enable it to get the Spyder 5 UX. In addition, this approach prevents cluttering the interface because the new buttons will be hidden when not needed.

So, could you check if that's working as expected for you?

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

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

Thanks @ccordoba12 ! Gave a local check and seems like things are working as expected 👍 Left a couple comments with nitpicks and a question regarding the tests wait logic (taking into account that now there is a signal available to determine when a toolbar gets rendered; maybe the wait are there to give some time for the toolbars to be rendered/rerendered after some action is done to them?) .

Anyhow, leaving this approved so feel free to merge if you think is ready


# Move the debug toolbar to be before the file one
toolbar.get_main().insertToolBar(file_toolbar, debug_toolbar)
qtbot.wait(500)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe for some of these qtbot.wait calls over these new tests could be replaced for a qtbot.waitSignal checking for the new toolbars sig_is_rendered signal?

container.create_toolbars_menu()
container.load_last_visible_toolbars()

def on_close(self, _unused):
container = self.get_container()

Copy link
Member

Choose a reason for hiding this comment

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

Should this blank be removed?

@@ -10,7 +10,7 @@

# Standard library imports
from collections import OrderedDict
from spyder.utils.qthelpers import SpyderAction
import logging
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't import logging go first/before from collections import OrderedDict too?

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.

Spyder 6: Debugging buttons missing from the main toolbar
2 participants