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

[WIP] PR: Add command line option to connect to an existing kernel at startup (IPython console) #23444

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Social-Mean
Copy link

@Social-Mean Social-Mean commented Jan 10, 2025

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)

Issue(s) Resolved

Fixes #23130

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: Social-Mean

@Social-Mean Social-Mean changed the title PR: IPython console: Start Spyder and connect to an existing ipython kernel [WIP] PR: IPython console: Start Spyder and connect to an existing ipython kernel Jan 10, 2025
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 @Social-Mean for your work on this!

spyder/app/cli_options.py Outdated Show resolved Hide resolved
cli_options = self.get_command_line_options()
connection_file = cli_options.connection_file
if connection_file is not None:
self.create_client_for_kernel(connection_file)
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be self.create_client_for_kernel(connection_file, give_focus=False) to give focus to the Editor and not the console at startup.

So, you need to improve that method to make it possible. For that:

  • Please add the give_focus kwarg to create_client_for_kernel.

  • Pass it to the main widget method here:

    return self.get_widget().create_client_for_kernel(
    connection_file, hostname, sshkey, password, server_id, can_close
    )

  • Add give_focus as a kwarg to the widget method too:

    def create_client_for_kernel(self, connection_file, hostname, sshkey,
    password, server_id=None, can_close=True):

  • Pass give_focus to the ClientWidget constructor:

    client = ClientWidget(
    self,
    id_=client_id,
    given_name=given_name,
    config_options=self.config_options(),
    additional_options=self.additional_options(),
    handlers=self.registered_spyder_kernel_handlers,
    server_id=server_id,
    can_close=can_close,
    )

@ccordoba12 ccordoba12 added this to the v6.0.4 milestone Jan 10, 2025
@ccordoba12 ccordoba12 changed the title [WIP] PR: IPython console: Start Spyder and connect to an existing ipython kernel [WIP] PR: Add command line option to connect to an existing kernel at startup (IPython console) Jan 10, 2025
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.

Add command line option to connect to an existing kernel
2 participants