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

Help needed to make a plugin work for spyder 6.* #23013

Open
gepcel opened this issue Nov 18, 2024 · 9 comments
Open

Help needed to make a plugin work for spyder 6.* #23013

gepcel opened this issue Nov 18, 2024 · 9 comments

Comments

@gepcel
Copy link
Contributor

gepcel commented Nov 18, 2024

I have made a plugin for spyder, which I’ve been using in spyder 5.* for years. I need help to make it work for spyder 6.*.

I’m not a programmer nor expert, I don’t know how to debug a plugin (I wrote scripts to process data usually). I’m hoping someone can point out what’s wrong, or some instruction or guidance I can follow. I’ve tried to start Spyder from the command line, and no useful message.

Plugin url: https://github.com/gepcel/ihelper

What’s plugin for?

There’s a useful function of spyder called “inspect current object”, which works differently for editor and ipython console. Sometimes, with a function or object, after Ctrl + I, I can’t get help information from editor, but can from ipython console. So I often need to copy some code to ipython console to get a help information, and go back to editor to work on. As a data scientist, I need this quite often.

So what this plugin mainly does is to find out the current object in editor and request help from help pane, pretend it’s a request from ipython console. And regist this to spyder plugin , add an entry to keyboard shortcut, and show in status bar.

@dalthviz
Copy link
Member

Hi @gepcel thank you for reaching out and sorry for the late response! Indeed there are some changes minimum that a plugin needs to do to be able to launch with Spyder 6 (as example of changes required you could check some PRs for external plugins like spyder-ide/spyder-line-profiler#87). Besides that, changes where done to the Editor so maybe that could be causing some troubles for your plugin too 🤔

I'm not totally sure what the specific problem could be for you plugin but if you can share a traceback or something similar maybe we could be able to at least point you into the right track for a fix. To get such a traceback maybe you will need to launch Spyder in debug mode. So from a terminal/cmd launch Spyder with the debug-info flag (spyder --debug-info verbose). You could also launch Spyder in debug mode from the Spyder GUI by using the Restart in debug mode option (File > Restart in debug mode).

Let us know if the info above helps/you have more debug information from your plugin!

@gepcel
Copy link
Contributor Author

gepcel commented Nov 21, 2024

Thanks.
Indeed, there's the same issue with spyder-line-profiler/pull/87, I've made the same changes commits. But there are still other problems.

  1. Inside Spyder preferences, this plugin shows up in the Plugins page, but not in the Keyboard shortcuts page.
  2. There should to be one entry in the Keyboard shortcuts page, so I can assign a shortcut to it.
  3. There is no show-up in the status bar. There used to be a status showing that the plugin loads up.

spyder-debug.log

@gepcel
Copy link
Contributor Author

gepcel commented Nov 21, 2024

Updates:

Now the plugin appears in statusbar and can appear in toolbar. The func works by clicking either the statusbar or toolbar. The plugin appears in keyboard shortcuts in preferences, and can be assigned to a shortcut key (Alt + I for example), but still doesn't work by pressing shortcut key.

@gepcel
Copy link
Contributor Author

gepcel commented Nov 22, 2024

@dalthviz Hi, sorry to bother. I appreciate some help here.

After trying fixing and some imitating, the plugin partially works. Now by clicking either the statusbar or the toolbar, the plugin works. But I registered an entry into Keyboard shortcuts page of preferences, assigned it to a shortcut key (Alt+G for example), but nothing happens after pressing the shortkey.

The shortcut registering code was mainly 7 lines. Would you mind take a look what I'm doing wrong?

@dalthviz
Copy link
Member

Hi again @gepcel ! I would say the code you have is the correct one to define the shortcut so I think that the issue you are experiencing is related with the fix being worked on over #23024 🤔 Could it be possible for you to check if running Spyder from that PR/branch helps? Let us know!

@dalthviz
Copy link
Member

Thinking about this a little bit more, maybe this is not related with #23024 and what is needed is passing to the action creation method something like context=Qt.ApplicationShortcut 🤔 Could you give it a try to that too please?

@gepcel
Copy link
Contributor Author

gepcel commented Nov 23, 2024

Passing context=Qt.ApplicationShortcut to the action creation method works, but it's on another computer. I'll double-check it when I'm back in the office.

@ccordoba12
Copy link
Member

@gepcel, do you want your shortcut to work globally, i.e. when pressed anywhere in Spyder? Or only when a specific plugin has focus, e.g. the Editor?

@gepcel
Copy link
Contributor Author

gepcel commented Nov 24, 2024

The shortcut only need to work when the Editor has focus.

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

No branches or pull requests

3 participants